arnaucube
arnaucube/go-iden3-cryptoPublic Self-hosted repository
Merge pull request #23 from iden3/feature/expose-method

Expose SkToBigInt for usage from other packages & repos
Eduard S eduard@iden3.io
Tue, 28 Apr 2020 18:31:15 +0200
commit

b1468fc0760ff436978b37ab4639c87378befac1

parent

14c3144613d44ac955580c9ef31f9a3c5bf70ccc

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M babyjub/eddsa.go → babyjub/eddsa.go

@@ -36,6 +36,13 @@

// Scalar converts a private key into the scalar value s following the EdDSA // standard, and using blake-512 hash. func (k *PrivateKey) Scalar() *PrivKeyScalar { + s := SkToBigInt(k) + return NewPrivKeyScalar(s) +} + +// SkToBigInt converts a private key into the *big.Int value following the +// EdDSA standard, and using blake-512 hash +func SkToBigInt(k *PrivateKey) *big.Int { sBuf := Blake512(k[:]) sBuf32 := [32]byte{} copy(sBuf32[:], sBuf[:32])

@@ -43,7 +50,7 @@ pruneBuffer(&sBuf32)

s := new(big.Int) utils.SetBigIntFromLEBytes(s, sBuf32[:]) s.Rsh(s, 3) - return NewPrivKeyScalar(s) + return s } // Pub returns the public key corresponding to a private key.