Skip to content

Conversation

@jannotti
Copy link
Contributor

@jannotti jannotti commented Aug 27, 2025

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

Copy link
Contributor

Copilot AI left a 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 sha512 opcode 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.

Copy link
Contributor

@algorandskiy algorandskiy left a 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?

@jannotti
Copy link
Contributor Author

jannotti commented Sep 4, 2025

looks like there should be a test checking the opcode against some blob with known sha512 hash?

Added in 14b53f0

@jannotti jannotti requested a review from gmalouf September 5, 2025 13:12
@jannotti jannotti merged commit 988c7d3 into algorand:master Sep 5, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants