AVM: sha512 opcode, txn commitments, #6424
Merged
jannotti merged 2 commits intoalgorand:masterfrom Sep 5, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
reviewed
Sep 4, 2025
Contributor
algorandskiy
left a comment
There was a problem hiding this comment.
looks like there should be a test checking the opcode against some blob with known sha512 hash?
Contributor
Author
Added in 14b53f0 |
algorandskiy
approved these changes
Sep 4, 2025
gmalouf
reviewed
Sep 5, 2025
gmalouf
approved these changes
Sep 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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