mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
refactor/internal (#1216)
* refactor: update import paths in gateway handlers * refactor: remove obsolete devtools Makefile and README * build: optimize build process for improved efficiency * refactor: remove obsolete pkl files related to Matrix and Sonr network configurations * refactor: move embed code to x/dwn/types
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
//
|
||||
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"crypto/elliptic"
|
||||
"math/big"
|
||||
|
||||
"filippo.io/edwards25519"
|
||||
)
|
||||
|
||||
func CalcFieldSize(curve elliptic.Curve) int {
|
||||
bits := curve.Params().BitSize
|
||||
return (bits + 7) / 8
|
||||
}
|
||||
|
||||
func ReverseScalarBytes(inBytes []byte) []byte {
|
||||
outBytes := make([]byte, len(inBytes))
|
||||
|
||||
for i, j := 0, len(inBytes)-1; j >= 0; i, j = i+1, j-1 {
|
||||
outBytes[i] = inBytes[j]
|
||||
}
|
||||
|
||||
return outBytes
|
||||
}
|
||||
|
||||
func BigInt2Ed25519Point(y *big.Int) (*edwards25519.Point, error) {
|
||||
b := y.Bytes()
|
||||
var arr [32]byte
|
||||
copy(arr[32-len(b):], b)
|
||||
return edwards25519.NewIdentityPoint().SetBytes(arr[:])
|
||||
}
|
||||
|
||||
func BigInt2Ed25519Scalar(x *big.Int) (*edwards25519.Scalar, error) {
|
||||
// big.Int is big endian; ed25519 assumes little endian encoding
|
||||
kBytes := ReverseScalarBytes(x.Bytes())
|
||||
var arr [32]byte
|
||||
copy(arr[:], kBytes)
|
||||
return edwards25519.NewScalar().SetCanonicalBytes(arr[:])
|
||||
}
|
||||
Reference in New Issue
Block a user