Skip to content

Commit

Permalink
fix: convert helper fn to use bn254 fp
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Oct 1, 2024
1 parent 3d460a1 commit 9d2e9d6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
"os"
"path/filepath"
"unicode"
Expand Down Expand Up @@ -496,9 +497,14 @@ func NewKeyPair(
return nil, err
}

// Parse to bn254 curve
// TODO: Take curve as param to generalize
fpKey := new(fr.Element).SetBigInt(key)
fpKeyBytes := fpKey.Bytes()

// Return key pair
return &KeyPair{
PrivateKey: key.Bytes(),
PrivateKey: fpKeyBytes[:],
Mnemonic: pkMnemonic,
Password: password,
}, nil
Expand All @@ -514,9 +520,14 @@ func NewKeyPairFromMnemonic(
return nil, err
}

// Parse to bn254 curve
// TODO: Take curve as param to generalize
fpKey := new(fr.Element).SetBigInt(key)
fpKeyBytes := fpKey.Bytes()

// Return key pair
return &KeyPair{
PrivateKey: key.Bytes(),
PrivateKey: fpKeyBytes[:],
Mnemonic: pkMnemonic,
Password: password,
}, nil
Expand Down

0 comments on commit 9d2e9d6

Please sign in to comment.