Skip to content

Commit

Permalink
stl: add merklization types into library
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Feb 11, 2024
1 parent 9f90575 commit ce4d602
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
5 changes: 5 additions & 0 deletions commit_verify/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ pub trait CommitmentId: Copy + Ord + From<Sha256> + StrictType {
/// concealment with [`crate::Conceal`], merklization, strict encoding,
/// wrapped into [`CommitEncode`], followed by the actual commitment to its
/// output.
///
/// The trait is separate from the `CommitEncode` to prevent custom
/// implementation of its methods, since `CommitId` can't be manually
/// implemented for any type since it has a generic blanket implementation.
pub trait CommitId: CommitEncode {
#[doc = hidden]
fn commit(&self) -> CommitEngine;

fn commitment_layout(&self) -> CommitmentLayout;
Expand Down
7 changes: 5 additions & 2 deletions commit_verify/src/stl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

use strict_types::{CompileError, LibBuilder, TypeLib};

use crate::{mpc, LIB_NAME_COMMIT_VERIFY};
use crate::{mpc, MerkleHash, MerkleNode, StrictHash, LIB_NAME_COMMIT_VERIFY};

pub const LIB_ID_COMMIT_VERIFY: &str =
"urn:ubideco:stl:4SZ2EgWWtC5LsNXmNpAzogNHZoaZNTCwU3SQhAYwDX6A#citizen-fiction-corner";
"urn:ubideco:stl:DYafq9UACuYbTpduhcqywBGH97wHYtSUNPiXh5v2Zub9#drama-imagine-extreme";

fn _commit_verify_stl() -> Result<TypeLib, CompileError> {
LibBuilder::new(libname!(LIB_NAME_COMMIT_VERIFY), tiny_bset! {
Expand All @@ -34,6 +34,9 @@ fn _commit_verify_stl() -> Result<TypeLib, CompileError> {
.transpile::<mpc::MerkleBlock>()
.transpile::<mpc::MerkleProof>()
.transpile::<mpc::Commitment>()
.transpile::<MerkleNode>()
.transpile::<MerkleHash>()
.transpile::<StrictHash>()
.compile()
}

Expand Down
36 changes: 20 additions & 16 deletions stl/[email protected]
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
-----BEGIN STRICT TYPE LIB-----
Id: 4SZ2EgWWtC5LsNXmNpAzogNHZoaZNTCwU3SQhAYwDX6A#citizen-fiction-corner
Id: DYafq9UACuYbTpduhcqywBGH97wHYtSUNPiXh5v2Zub9#drama-imagine-extreme
Name: CommitVerify
Dependencies:
55f8bsTvyh7zAeYAiNwL9G1DxgwXzDvE8edcTFJz3Q9H#milan-poncho-gray

3`1{iZE18?WpZg|c>z42FO<H1_-S;rS?5kSkETnEdbK=gZ!JlvFJ#}N3>*VfbYuY
oQ*>kj0A^Tl*p6J$36SYb7g#;qpQBTpwL(~+!(f@;t~vt?k^)sV2mlI0Z*6U9bZu
oQ*>kj0A^Tl*p6J$36SYb7g#;qpQBTpwL(~+!(f@;t~vt?k^)sV3jhj3Z*6U9bZu
pBbOiwb2LJ#-AOH(ZWpZn5WkPIkV`~Nk1!QG#bZ7!Rpf8lZe)ws0vsvd(H;<-EjC
!>^Xm2e^s4rySqYNBoSa8^mT+s=T=}Z?`J=~w8Q=GLzSfImTncuED0}GM}V{c|*V
{~tF0006EV{&hEb5mtwbZKvH00;rtwYiq_Rlwao{(T?aUNqayF^88E^#IUpx^^~;
)zDV}0000000030|Ns9000007Wo~qGZ*X}41OfmAZf|a7000011aog~WdH>M000O
IO=WUxY-LDcb7%zt00#g7Kp+4MO=WUxY-Lb#Z*OJ>0|Rhxa{vGY2xD(%VPkY}asU
7V1aM(=XaEQSIG#g>Clv)aMjKgwAH@`bu1x<7g|G$};xvA~n-$_S0000000000AO
HXW000003Qc8lYiwmya%E)(1qEbfaCB$_JfJU>zJB;=bhBCKPB)LHON@H8JZNt%N
vJPm-=hp1W>|38j$F|Rkm*bpSUudIqf?x<LRg@~V42^pIs*%m2W4(_a&K^X000OG
V{c|*V{~tF0006AZDn(FVP|D?015#xm44<OVKiC01qkHfuRUrZzt;Qv9WjEZdF4f
P;8w8#H8-hI70Bv^+*0?ef%0)>Q3WP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bltNdpi4*91)SI!>0000000000|Ns9000000
18re&015yA1ONpB0Wg(*<{e=)S-S-Y<l(P9Y9YVY`}-X+f~R@qMRed+u>mzVsZkZ
k>V@1=_p5>Oab-~jCR3C`SFec^=zG+gvC{wm0000000960{{R30000L~Wpi_3XJr
Ke00#g7Kp+4OPH$voLULhlV`yn^X9EKSc5i8900whuZf9&|0S01nVQyn+0t!%aZ*
*^CZ){0q1pxpD002NB018uda%p39NMUnm1pxpD002NB00>laWo1rpWMu>b01abrZ
ewL(Y-MClZ)9Zv1_A|SWpH$80z9BEl)irWX>_w$=T0||rb~=^wLEBVElH>^WZ$C<
9A;Q>*p6J$36SYb7g#;qpQBTpwL(~+!(f@;t~vt?k_2dBb7%oLo<oKw6$Lm(8(Du
J#T0?AO#cjpum%_6G=9FD72-1i4r6a^ZE19EWo~p#WnpFj1_BCja&L5RV{dFpWC1
Xhe&!uvG+Da^2;||fJ!&Dp*8BS%F@mRg<wbPhR<Q?dWpi_3XJr93H>pt-$m)gMQu
nKY@^NKR1twFJLRYVe6X<)?o3Ya

-----END STRICT TYPE LIB-----

Binary file modified stl/[email protected]
Binary file not shown.
16 changes: 15 additions & 1 deletion stl/[email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-
Id: urn:ubideco:stl:4SZ2EgWWtC5LsNXmNpAzogNHZoaZNTCwU3SQhAYwDX6A#citizen-fiction-corner
Id: urn:ubideco:stl:DYafq9UACuYbTpduhcqywBGH97wHYtSUNPiXh5v2Zub9#drama-imagine-extreme
Name: CommitVerify
Version: 0.1.0
Description: Client-side-validation deterministic commitments
Expand Down Expand Up @@ -27,6 +27,13 @@ data MerkleBlock : depth Std.U5#nitro-george-nebula
@mnemonic(culture-metro-modular)
data MerkleHash : [Byte ^ 32]

@mnemonic(input-mouse-amber)
data MerkleNode : branching NodeBranching
, depth U8
, width U16
, node1 MerkleHash
, node2 MerkleHash

@mnemonic(father-adios-common)
data MerkleProof : pos U32
, cofactor U16
Expand All @@ -42,9 +49,16 @@ data MerkleTree : depth Std.U5#nitro-george-nebula
@mnemonic(shampoo-bishop-morgan)
data Message : [Byte ^ 32]

@mnemonic(food-amanda-burger)
data NodeBranching : void | single | branch


@mnemonic(gamma-banjo-corona)
data ProtocolId : [Byte ^ 32]

@mnemonic(cheese-final-locate)
data StrictHash : [Byte ^ 32]

@mnemonic(empty-active-truck)
data TreeNode : concealedNode (depth Std.U5#nitro-george-nebula, hash MerkleHash)
| commitmentLeaf (protocolId ProtocolId, message Message)
Expand Down

0 comments on commit ce4d602

Please sign in to comment.