Skip to content
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

AVM: Adding sumhash and falcon_verify #5599

Merged
merged 2 commits into from Jan 5, 2024

Conversation

jannotti
Copy link
Contributor

@jannotti jannotti commented Jul 24, 2023

This should allow the AVM to check state proofs and/or create PQ safe Algorand accounts

AVM state proof checking would still be a lot of work. State proofs are really big, so the verification would have to be incremental, by feeding in parts of the proof a little at a time.

It should be possible to create PQ safe accounts today with falcon_verify by creating a logicsig that approves if the logicsig args conatin a falcon signature of the transaction. An extra precaution would be to ensure that the logicsig address (formed by hash of program) is an invalid ed25519 public key.

There is at least a little interest in sumhash512 on its own as well, since it is a zk friendly hash.

These opcodes would be kept "experimental" (always one version beyond mainnet) until they are proven sufficient for something useful.

@jannotti jannotti self-assigned this Jul 24, 2023
@jannotti jannotti changed the title Adding sumhash and falcon_verify AVM: Adding sumhash and falcon_verify Jul 24, 2023
@jannotti jannotti force-pushed the avm-stateproof-opcodes branch 2 times, most recently from ac0b426 to 7817578 Compare July 24, 2023 17:35
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (e7aa0d4) 55.95% compared to head (175401e) 55.92%.

Files Patch % Lines
data/transactions/logic/crypto.go 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5599      +/-   ##
==========================================
- Coverage   55.95%   55.92%   -0.03%     
==========================================
  Files         477      477              
  Lines       67436    67455      +19     
==========================================
- Hits        37736    37727       -9     
- Misses      27149    27168      +19     
- Partials     2551     2560       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jannotti
Copy link
Contributor Author

It is likely that a state proof checking AVM contract would also need access to this:

// LnIntApproximation returns a uint64 approximation
func LnIntApproximation(x uint64) (uint64, error) {
	if x == 0 {
		return 0, ErrIllegalInputForLnApprox
	}
	result := math.Log(float64(x))
	precision := uint64(1 << precisionBits)
	expandWithPrecision := result * float64(precision)
	return uint64(math.Ceil(expandWithPrecision)), nil
}

as an opcode.

@HashMapsData2Value
Copy link

HashMapsData2Value commented Aug 8, 2023

Out of curiosity would this enable:

  1. Trustless bridging from an Algorand co-chain (or anything making use of state proofs) to Algorand, without having to snarkify the state proof?

  2. The ability to prove to Algorand today that something, a transaction, took place in its distance past (beyond the 1000 block limit)?

@jannotti
Copy link
Contributor Author

jannotti commented Aug 8, 2023

The intention was to allow 1. But this is a low priority thing I did for fun one day. We'd need someone to put in the effort to show it could be done before pushing this into mainnet.

I don't think it gives you 2, unless you implement fast catch-up by going through state proofs in an AVM contract. Maybe?

This should allow the AVM to check state proofs
data/transactions/logic/opcodes.go Outdated Show resolved Hide resolved
data/transactions/logic/crypto_test.go Outdated Show resolved Hide resolved
data/transactions/logic/crypto_test.go Outdated Show resolved Hide resolved
@jannotti jannotti marked this pull request as ready for review January 5, 2024 17:58
@jannotti jannotti merged commit 21eec2d into algorand:master Jan 5, 2024
18 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.

None yet

6 participants