Skip to content

Develop branch. Convert ecdsa.PublicKey to []uints.U8 for ethereum address recovery #802

Closed Answered by ivokub
NikitaMasych asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @NikitaMasych, right now we don't have convenience methods. Some time ago I also needed something similar and realised that it is easier to provide the public key serialised as bytes as additional witness, convert it to pubkey using the method BytesToPublicKey below and then show that the obtained pubkey corresponds to the one we are checking against.

See the following snippet. It is for P384, but should be easily modifiable for P256.

func byteArrayToLimbs(api frontend.API, array []uints.U8) ([]frontend.Variable, error) {
	ret := make([]frontend.Variable, (len(array)+7)/8)
	ap := make([]uints.U8, 8*len(ret)-len(array))
	for i := range ap {
		ap[i] = uints.NewU8(0)
	}
	array = append(ap, 

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@NikitaMasych
Comment options

Answer selected by NikitaMasych
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants