Have implemented a smart signature contract account where funds in the escrow can be pulled by the receiver only if the receiver’s address has been signed by a secret key, yielding a signature, which is then verified against the related public key (embedded in the contract).
Following are the relevant snippets - I’m missing something in the interplay between calling the contract and the ed25519verify_bare TEAL code - any suggestions appreciated
— Public/Secret Key Setup —
const keys = nacl.sign.keyPair();
const publicKeyBytes = keys.publicKey;
const secretKeyBytes = keys.secretKey;
const recipientAddress = “OKKGIO…”; // Valid Account Address
const signature = nacl.sign.detached(Buffer.from(recipientAddress), secretKeyBytes);
const verify = nacl.sign.detached.verify(Buffer.from(recipientAddress), signature, publicKeyBytes);
console.log(‘verify’, verify); // Verified!
– SDK –
const pubKey = Buffer.from(publicKeyBytes).toString(“base64”);
// NOTE pubKey gets injected into the TEAL as below, pre-compilation
…
let smartSigArgs = ;
smartSigArgs.push(Buffer.from(“rcv”));
smartSigArgs.push(signature); // arg 1 below
const smartSig = new algosdk.LogicSigAccount(compiledCodeBytes, smartSigArgs);
— TEAL —
gtxn 1 AssetReceiver // same as recipientAddress above
arg 1 // Signature
pushbytes b64 ${pubKey}
ed25519verify_bare
bz handle_fail // Always fails