sophia/test/contracts/qr_auth.aes
Ulf Wiger ed72e393ab
Some checks failed
Sophia Tests / tests (push) Failing after -4m44s
1st commit: add MLDSA sig verification
2026-01-29 14:14:33 +01:00

22 lines
800 B
Plaintext

// Contract using Quantum-Resistant signing (MLDSA65)
contract QrAuth =
record state = { nonce : int, owner : address, owner_pub : bytes }
entrypoint init(pub : bytes) = { nonce = 1
, owner = Call.caller
, owner_pub = pub }
stateful entrypoint authorize(n : int, s : signature) : bool =
require(n >= state.nonce, "Nonce too low")
require(n =< state.nonce, "Nonce too high")
put(state{ nonce = n + 1 })
switch(Auth.tx_hash)
None => abort("Not in Auth context")
Some(tx_hash) => Crypto.verify_sig_mldsa65(to_sign(tx_hash, n), state.owner_pub, s)
entrypoint to_sign(h : hash, n : int) =
Crypto.blake2b((h, n))
entrypoint weird_string() : string =
"\x19Weird String\x42\nMore\n"