Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
const tree_root = mimc7.multiHash([aliceHash, bobHash])
// transaction
const tx = {
from: Alice.pubkey,
detail: 0,
updated_pubkey: Alice.pubkey
}
// Alice sign tx
const txHash = mimc7.multiHash(
[tx.from[0], tx.from[1], BigInt(tx.detail), tx.updated_pubkey[0], tx.updated_pubkey[1]]
)
const signature = eddsa.signMiMC(alicePrvKey, txHash)
// update Alice account
const newAlice = {
pubkey: tx.updated_pubkey,
detail: BigInt(tx.detail)
}
const newAliceHash = mimc7.multiHash(
[newAlice.pubkey[0], newAlice.pubkey[1], BigInt(newAlice.detail)]
)
// update root
const final_root = mimc7.multiHash([newAliceHash, bobHash])
// console.log('tree_root: ' + tree_root.toString())
// console.log('final_root: ' + final_root.toString())
// console.log('accounts_pubkeys Alice.pubkey[0]: ' + Alice.pubkey[0].toString())
// Wait 10 seconds
console.log('Sleeping 10 seconds...')
await sleep(10000)
console.log('Woken up')
// Construct 2nd message
const userSecondMessage = [
...userPosition,
...userPubKey,
1n // New position
]
const userSecondMessageHash = mimc7.multiHash(userSecondMessage)
const secondSignature: MiMicSignature = eddsa.signMiMC(
userPrvKey.toString(),
userSecondMessageHash
)
// Insert signature into tx
const userSecondMessage2 = [
...userSecondMessage,
secondSignature.R8[0],
secondSignature.R8[1],
secondSignature.S
]
const userSecondEncryptedMessage = encrypt(
userSecondMessage2,
userPrvKey,
coordinatorPublicKey
const pk = stringifyBigInts(userPubKey)
// First message (insert new user)
const userPosition: Array = [
...userPubKey,
0n // Action
]
const userInitialMessage = [
...userPosition,
0n, 0n, 0n
]
const userMessageHash = mimc7.multiHash(userInitialMessage)
const signature: MiMicSignature = eddsa.signMiMC(
userPrvKey.toString(),
userMessageHash
)
// Insert signature into tx
const userInitialMessage2 = [
...userInitialMessage,
signature.R8[0],
signature.R8[1],
signature.S
]
const userInitialEncryptedMessage = encrypt(
userInitialMessage2,
userPrvKey,
coordinatorPublicKey
signMimc7(msg: bigInt): Signature {
const s = eddsa.signMiMC(this.sk, msg);
return new Signature(s.R8, s.S);
}