Skip to content

Commit

Permalink
update to use MPF over SMT
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Jun 3, 2024
1 parent 94e17e8 commit 3d3e800
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
16 changes: 7 additions & 9 deletions aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[[requirements]]
name = "aiken-lang/stdlib"
version = "main"
version = "1.9.0"
source = "github"

[[requirements]]
Expand All @@ -12,13 +12,13 @@ version = "main"
source = "github"

[[requirements]]
name = "aiken-lang/sparse-merkle-tree"
version = "main"
name = "aiken-lang/merkle-patricia-forestry"
version = "1.0.1"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "main"
version = "1.9.0"
requirements = []
source = "github"

Expand All @@ -29,12 +29,10 @@ requirements = []
source = "github"

[[packages]]
name = "aiken-lang/sparse-merkle-tree"
version = "main"
name = "aiken-lang/merkle-patricia-forestry"
version = "1.0.1"
requirements = []
source = "github"

[etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1716768169, nanos_since_epoch = 70954000 }, "98cf81aa68f9ccf68bc5aba9be06d06cb1db6e8eff60b668ed5e8ddf3588206b"]
"aiken-lang/sparse-merkle-tree@main" = [{ secs_since_epoch = 1716768169, nanos_since_epoch = 260225000 }, "d62835502559dd73280353f1c05ac41379d4523350813deeced8ebf915935a7f"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1716768168, nanos_since_epoch = 952011000 }, "dfda6bc70aad760f7f836c0db06b07e0a398bb3667f4d944d7d7255d54a454af"]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1717431188, nanos_since_epoch = 729743000 }, "98cf81aa68f9ccf68bc5aba9be06d06cb1db6e8eff60b668ed5e8ddf3588206b"]
8 changes: 5 additions & 3 deletions aiken.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name = "aiken-lang/fortuna"
version = "0.0.0"
compiler = "v1.0.28-alpha"
plutus = "v2"
license = "Apache-2.0"
description = "Aiken contracts for pow coin"

Expand All @@ -10,7 +12,7 @@ platform = "github"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "main"
version = "1.9.0"
source = "github"

[[dependencies]]
Expand All @@ -19,6 +21,6 @@ version = "main"
source = "github"

[[dependencies]]
name = "aiken-lang/sparse-merkle-tree"
version = "main"
name = "aiken-lang/merkle-patricia-forestry"
version = "1.0.1"
source = "github"
24 changes: 9 additions & 15 deletions validators/tunav2.ak
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use aiken/builtin
use aiken/bytearray
use aiken/dict
use aiken/hash.{Hash, Sha2_256, blake2b_256, sha2_256}
use aiken/hash.{blake2b_256, sha2_256}
use aiken/interval.{Finite, Interval, IntervalBound}
use aiken/list
use aiken/math.{pow2}
use aiken/merkle_patricia_forestry.{Proof, from_root, insert}
use aiken/pairs
use aiken/sparse_merkle_tree/merkle_blake256.{MerkleProofBlock}
use aiken/sparse_merkle_tree_blake256.{verify_added_member}
use aiken/transaction.{
InlineDatum, Mint, Output, OutputReference, ScriptContext, Spend, Transaction,
} as tx
Expand Down Expand Up @@ -64,11 +63,7 @@ type Miner {
}

type MineAction {
MinePow(
ByteArray,
Miner,
MerkleProofBlock<Hash<Sha2_256, Hash<Sha2_256, TargetState>>>,
)
MinePow(ByteArray, Miner, Proof)
Upgrade
}

Expand Down Expand Up @@ -743,7 +738,7 @@ validator(fortuna_v1_hash: Data, fork_script_hash: Data) {
validator(tunav2_minting_policy: ByteArray) {
fn mine(datum: Statev2, redeemer: MineAction, ctx: ScriptContext) -> Bool {
when redeemer is {
MinePow(nonce, miner, merkle_proof_block) -> {
MinePow(nonce, miner, merkle_proof_list) -> {
let Statev2 {
block_number,
current_hash,
Expand Down Expand Up @@ -906,13 +901,12 @@ validator(tunav2_minting_policy: ByteArray) {
// Spend(12) requirement: Output current hash is the found hash
(out_current_hash == found_bytearray)?,
// Spend(13) requirement: Check output merkle is correct
verify_added_member(
(insert(
merkle_root |> from_root,
found_bytearray |> blake2b_256,
found_bytearray,
identity,
merkle_proof_block,
merkle_root,
out_merkle,
)?,
merkle_proof_list,
) == from_root(out_merkle))?,
}
}

Expand Down

0 comments on commit 3d3e800

Please sign in to comment.