Sinature Varification

38 views Asked by At

I have a text message, let's say: "HELLO, WORLD" that is signed with multiple keypairs using npm package tweetnacl, using method nacl.sign.detached. I would like to understand here, if I can sign with 3 keys on the single message and verify all three signatures using tweetnacl. I did practicals with 1 Key to sign a message, and I'm able to verify it.please have a look at code for same:

import nacl from "tweetnacl";

let signedMessage = nacl.sign.detached(MSG, baseAccount.secretKey); // sign message using Ed25519
let is_verify = nacl.verify(signedMessage , baseAccount.publicKey.toBytes())

 // Ed25519 instruction
    let ix01 = anchor.web3.Ed25519Program.createInstructionWithPublicKey(
      {
        publicKey: baseAccount.publicKey.toBytes(), // The public key associated with the instruction (as bytes)
        message: MSG,  // The message to be included in the instruction (as a Buffer)
        signature: signedMessage, // The signature associated with the instruction (as a Buffer)
        // instructionIndex: 0
      }
    )```
Just to understand with respect to cryptography concept, would I be able to sign a text with 3 keypairs and verify that signed message later point in time, by passing 3 public keys. 
1. How we can accomplish this in a simple node script?
2. Can anyone please guide me through the process of verifying multiple signatures and implementing it within a Solana smart contract? I see in Solana docs, that it supports: `Multiple signatures can be verified. If any of the signatures fail to verify, an error is returned.` https://docs.solana.com/developing/runtime-facilities/programs#ed25519-program. Can I get reference git URL for same?

I did practicals with 1 Key to sign a message, and I'm able to verify it.please have a look at code for same
``JS
import nacl from "tweetnacl";

let signedMessage = nacl.sign.detached(MSG, baseAccount.secretKey); // sign message using Ed25519
let is_verify = nacl.verify(signedMessage , baseAccount.publicKey.toBytes())

 // Ed25519 instruction
    let ix01 = anchor.web3.Ed25519Program.createInstructionWithPublicKey(
      {
        publicKey: baseAccount.publicKey.toBytes(), // The public key associated with the instruction (as bytes)
        message: MSG,  // The message to be included in the instruction (as a Buffer)
        signature: signedMessage, // The signature associated with the instruction (as a Buffer)
        // instructionIndex: 0
      }
    )```
Just to understand with respect to cryptography concept, would I be able to sign a text with 3 keypairs and verify that signed message later point in time, by passing 3 public keys. 
1. How we can accomplish this in a simple node script?
2. Can anyone please guide me through the process of verifying multiple signatures and implementing it within a Solana smart contract? I see in Solana docs, that it supports: `Multiple signatures can be verified. If any of the signatures fail to verify, an error is returned.` https://docs.solana.com/developing/runtime-facilities/programs#ed25519-program. Can I get reference git URL for same?
0

There are 0 answers