-
Notifications
You must be signed in to change notification settings - Fork 518
AVM: sha512 opcode, txn commitments, #6424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces SHA-512 cryptographic capabilities to the Algorand Virtual Machine (AVM) by adding a new sha512 opcode and providing access to transaction commitments from previous blocks using different hash algorithms.
- Adds the
sha512opcode with cost adjustments based on input length - Introduces new block fields for accessing previous block's transaction commitments (sha512_256, sha256, sha512) and wider sha-512 hash
- Updates syntax highlighting and documentation to include the new cryptographic functionality
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| data/transactions/logic/opcodes.go | Adds the sha512 opcode definition with version 13 and length-based cost calculation |
| data/transactions/logic/crypto.go | Implements the opSHA512 function that computes SHA-512 hash |
| data/transactions/logic/fields.go | Defines new block fields for transaction commitments and sha512 hash access |
| data/transactions/logic/eval.go | Implements block field evaluation for the new commitment and hash fields |
| data/transactions/logic/fields_string.go | Updates string representations for new block fields |
| data/transactions/logic/doc.go | Adds documentation and categorization for the sha512 opcode |
| data/transactions/logic/teal.tmLanguage.json | Updates TEAL syntax highlighting to include sha512 |
| data/transactions/logic/assembler_test.go | Adds test cases for sha512 opcode and new block fields |
| data/transactions/logic/crypto_test.go | Includes sha512 in cryptographic benchmark tests |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
algorandskiy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there should be a test checking the opcode against some blob with known sha512 hash?
Added in 14b53f0 |
Summary
This PR provides access to previous block's txn commitments in the AVM, the sha512 hash of the previous block, and a sha512 opcode so that programs could use these things.
The sha512 cost adjusts for length. The existing hashes (sha512_256, keecak, sha256) should probably all be adjusted to do so as well. (sha512_256 would presumably get the same cost as sha512).
Test Plan