From d189a6bedc6bd1b8564f8b4e914955e9ea5b2251 Mon Sep 17 00:00:00 2001 From: arnaucube Date: Wed, 22 Apr 2020 14:53:31 +0200 Subject: [PATCH] Expose SkToBigInt for usage from other packages & repos --- babyjub/eddsa.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/babyjub/eddsa.go b/babyjub/eddsa.go index 3093a4a..f2c9b32 100644 --- a/babyjub/eddsa.go +++ b/babyjub/eddsa.go @@ -36,6 +36,13 @@ func NewRandPrivKey() PrivateKey { // 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 @@ func (k *PrivateKey) Scalar() *PrivKeyScalar { 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.