Conversation
|
@noot Implemented VRF sign and verify for keypair type as well as a secretKey to KeyPair method, so this should be good to go. Let me know if you want anything else! |
|
@EclesioMeloJunior updated! |
keys.go
Outdated
| return &PublicKey{key: e.ScalarBaseMult(sc)}, nil | ||
| } | ||
|
|
||
| // Keypair Generates the keypair corresponding to this SecretKey |
There was a problem hiding this comment.
| // Keypair Generates the keypair corresponding to this SecretKey | |
| // Keypair returns the keypair corresponding to this SecretKey |
| } | ||
|
|
||
| // NewKeypair creates a new keypair from a public key and secret key | ||
| func NewKeypair(pk *PublicKey, sk *SecretKey) *Keypair { |
There was a problem hiding this comment.
could you add a *Keypair.PublicKey() function to return the public key so that PublicKey.Verify() can be called? alternatively you can make a Verify function on Keypair
There was a problem hiding this comment.
I'm thinking ill make a Verify function on Keypair if that works for you!
vrf.go
Outdated
| sk := kp.secretKey | ||
| p, err := sk.vrfCreateHash(t) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| extra := merlin.NewTranscript(VRFLabel) | ||
| proof, err := sk.dleqProve(extra, p) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| return p, proof, nil |
There was a problem hiding this comment.
can you just call kp.secretKey.VrfSign() instead of copy pasting?
vrf.go
Outdated
| if t == nil { | ||
| return false, errors.New("transcript provided is nil") | ||
| } | ||
|
|
||
| if out == nil { | ||
| return false, errors.New("output provided is nil") | ||
| } | ||
|
|
||
| if proof == nil { | ||
| return false, errors.New("proof provided is nil") | ||
| } | ||
|
|
||
| if kp.publicKey == nil { | ||
| return false, errors.New("publicKey is nil") | ||
| } | ||
|
|
||
| pk := kp.publicKey | ||
| if pk.key.Equal(publicKeyAtInfinity) == 1 { | ||
| return false, errPublicKeyAtInfinity | ||
| } | ||
|
|
||
| inout, err := out.AttachInput(pk, t) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
||
| t0 := merlin.NewTranscript(VRFLabel) | ||
| return pk.dleqVerify(t0, inout, proof) |
There was a problem hiding this comment.
same here, just call kp.publicKey.VrfVerify()
|
@noot updated! Let me know if there's anything else to change |
Created a keypair type that contains both a public and private key and a corresponding sign function.
I can further refactor to utilize the keypair if need be (ie. have GenerateKeypair return a keypair)
closes #44