Need syntax/example to use ed25519verify inside TEAL

Hi All, I did not find any example/template TEAL that uses ed25519verify to verify signature inside a smart contract. Please provide an example if you have one.

ed25519verify

  • Opcode: 0x04
  • Pops: … stack , {byte A}, {byte B}, {byte C}
  • Pushes: uint64
  • for (data A, signature B, pubkey C) verify the signature of (“ProgData” || program_hash || data) against the pubkey => {0 or 1}
  • Cost : 1900

The 32 byte public key is the last element on the stack, preceeded by the 64 byte signature at the second-to-last element on the stack, preceeded by the data which was signed at the third-to-last element on the stack.

byte base64 iZWMx72KvU6Bw6sPAWQFL96YH+VMrBA0XKWD9XbZOZI=
byte base64 if8ooA+32YZc4SQBvIDDY8tgTatPoq4IZ8Kr+We1t38LR2RuURmaVu9D4shbi4VvND87PUqq5/0vsNFEGIIEDA==
addr 7JOPVEP3ABJUW5YZ5WFIONLPWTZ5MYX5HFK4K7JLGSIAG7RRB42MNLQ224
ed25519verify

The order should be left to right for order of pushing parameters onto the stack

thanks for the quick response. Will try and respond back.


$ ./goal clerk dryrun -t tx1.txn -d data
tx[0] cost=1904 trace:
  1 bytecblock => 
134 bytec_0 => 89958cc7bd8abd4e81c3ab0f0164052fde981fe54cac10345ca583f576d93992
135 bytec_1 => 89ff28a00fb7d9865ce12401bc80c363cb604dab4fa2ae0867c2abf967b5b77f0b47646e51199a56ef43e2c85b8b856f343f3b3d4aaae7fd2fb0d1441882040c
136 bytec_2 => fa5cfa91fb00534b7719ed8a87356fb4f3d662fd3955c57d2b3490037e310f34
137 ed25519verify => 0 0x0

REJECT

Why does it reject?

What is the meaning of “for (data A, signature B, pubkey C) verify the signature of (“ProgData” || program_hash || data) against the pubkey => {0 or 1}” What is ProgData here? Can you give a full, working example?

We do not have a simple of example of using this function at the moment but we will get one in the future with some possible SDK changes. The data to be verified must also include the actual TEAL program hash. This is done so that signatures are only valid for one particular contract. We have a utility for signing the data that you can use called dsign but you will need to download the source and build to get it. We are using this function in the delegate key registration template https://github.com/algorand/go-algorand/blob/master/tools/teal/templates/delegate-key-registration.teal.tmpl
You can look at this shell script for an example of how this can be used: https://github.com/algorand/go-algorand/blob/master/tools/teal/examples/keyreg.sh