Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

keypair_verify and ed25519 support #3

Closed
roccomuso opened this issue Oct 7, 2020 · 6 comments
Closed

keypair_verify and ed25519 support #3

roccomuso opened this issue Oct 7, 2020 · 6 comments

Comments

@roccomuso
Copy link

Even though I know it's not recommended to use keypair_ calls in a user-facing application I'm wondering if ed25519 support is planned

image

@arjanz
Copy link
Member

arjanz commented Oct 8, 2020

Yes you are right, the keypair_* method are merely to showcase the underlying functionality the library https://github.com/polkascan/py-substrate-interface offers, I think this should be your entrypoint if you want to develop an application in Python.

I will look into ed25519 support, the RUST bindings are already made but I need to run some tests to verify

@arjanz
Copy link
Member

arjanz commented Oct 26, 2020

Added Ed25519 support in e3a8429

@arjanz arjanz closed this as completed Oct 26, 2020
@arjanz
Copy link
Member

arjanz commented Oct 27, 2020

@roccomuso Is this working for you?

@roccomuso
Copy link
Author

So, the keypair_verify seems to be working (returning true) with my local data, signature and address.
But the keypair_sign produces a different signature using the same mnemonic and data.

@arjanz
Copy link
Member

arjanz commented Nov 2, 2020

I tested the keypair_sign with the provided default mnemonic, but it seems to correctly result in the same signature as subkey does:

echo -n "test" | subkey --network=kusama -e sign "hope advance orange pool weather tuition caught notable letter calm panda approve"

Results in the same signature as Substrate Interface GUI: 0xbdd2911656fe0d757836806d807ce5236ffb645157387bf000561c1c8afd68c1b4cf7ea72e27098a5ffa6d5ec782d313ac237ca4c58288fa3adfa6535c654606

How did you generate your signature?

@roccomuso
Copy link
Author

Ok I've been able to do it. It was actually a mnemonic issue. Looks fine!

Btw that's the JS code:

const nacl = require('tweetnacl')

// get seed through mnemonicToMiniSecret of @polkadot/util-crypto
const seed = '9fd95cf77e54b516696a86f6819fd1f96cc7604f0577a2ab892081c39e44a61a'
const data = Buffer.from('test')

const { secretKey } = nacl.sign.keyPair.fromSeed(Buffer.from(seed, 'hex'))
const signature = nacl.sign.detached(data, secretKey)

console.log('0x' + Buffer.from(signature).toString('hex'))
// 0xbdd2911656fe0d757836806d807ce5236ffb645157387bf000561c1c8afd68c1b4cf7ea72e27098a5ffa6d5ec782d313ac237ca4c58288fa3adfa6535c654606

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants