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

Miniscript jets #107

Merged
merged 5 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions C/dag.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,34 @@ static sha256_midstate imr_disconnectIV,
static sha256_midstate identityIV,
hiddenIV;
static void static_initialize(void) {
MK_TAG(&cmr_compIV, COMMITMENT_TAG("comp"));
MK_TAG(&cmr_caseIV, COMMITMENT_TAG("case"));
MK_TAG(&cmr_pairIV, COMMITMENT_TAG("pair"));
MK_TAG(&cmr_disconnectIV, COMMITMENT_TAG("disconnect"));
MK_TAG(&cmr_injlIV, COMMITMENT_TAG("injl"));
MK_TAG(&cmr_injrIV, COMMITMENT_TAG("injr"));
MK_TAG(&cmr_takeIV, COMMITMENT_TAG("take"));
MK_TAG(&cmr_dropIV, COMMITMENT_TAG("drop"));
MK_TAG(&cmr_idenIV, COMMITMENT_TAG("iden"));
MK_TAG(&cmr_unitIV, COMMITMENT_TAG("unit"));
MK_TAG(&cmr_witnessIV, COMMITMENT_TAG("witness"));
MK_TAG(&amr_compIV, ANNOTATED_TAG("comp"));
MK_TAG(&amr_assertlIV, ANNOTATED_TAG("assertl"));
MK_TAG(&amr_assertrIV, ANNOTATED_TAG("assertr"));
MK_TAG(&amr_caseIV, ANNOTATED_TAG("case"));
MK_TAG(&amr_pairIV, ANNOTATED_TAG("pair"));
MK_TAG(&amr_disconnectIV, ANNOTATED_TAG("disconnect"));
MK_TAG(&amr_injlIV, ANNOTATED_TAG("injl"));
MK_TAG(&amr_injrIV, ANNOTATED_TAG("injr"));
MK_TAG(&amr_takeIV, ANNOTATED_TAG("take"));
MK_TAG(&amr_dropIV, ANNOTATED_TAG("drop"));
MK_TAG(&amr_idenIV, ANNOTATED_TAG("iden"));
MK_TAG(&amr_unitIV, ANNOTATED_TAG("unit"));
MK_TAG(&amr_witnessIV, ANNOTATED_TAG("witness"));
MK_TAG(&imr_disconnectIV, IDENTITY_TAG("disconnect"));
MK_TAG(&imr_witnessIV, IDENTITY_TAG("witness"));
MK_TAG(&identityIV, SIMPLICITY_PREFIX "\x1F" "Identity");
MK_TAG(&hiddenIV, SIMPLICITY_PREFIX "\x1F" "Hidden");
MK_TAG(cmr_compIV.s, COMMITMENT_TAG("comp"));
MK_TAG(cmr_caseIV.s, COMMITMENT_TAG("case"));
MK_TAG(cmr_pairIV.s, COMMITMENT_TAG("pair"));
MK_TAG(cmr_disconnectIV.s, COMMITMENT_TAG("disconnect"));
MK_TAG(cmr_injlIV.s, COMMITMENT_TAG("injl"));
MK_TAG(cmr_injrIV.s, COMMITMENT_TAG("injr"));
MK_TAG(cmr_takeIV.s, COMMITMENT_TAG("take"));
MK_TAG(cmr_dropIV.s, COMMITMENT_TAG("drop"));
MK_TAG(cmr_idenIV.s, COMMITMENT_TAG("iden"));
MK_TAG(cmr_unitIV.s, COMMITMENT_TAG("unit"));
MK_TAG(cmr_witnessIV.s, COMMITMENT_TAG("witness"));
MK_TAG(amr_compIV.s, ANNOTATED_TAG("comp"));
MK_TAG(amr_assertlIV.s, ANNOTATED_TAG("assertl"));
MK_TAG(amr_assertrIV.s, ANNOTATED_TAG("assertr"));
MK_TAG(amr_caseIV.s, ANNOTATED_TAG("case"));
MK_TAG(amr_pairIV.s, ANNOTATED_TAG("pair"));
MK_TAG(amr_disconnectIV.s, ANNOTATED_TAG("disconnect"));
MK_TAG(amr_injlIV.s, ANNOTATED_TAG("injl"));
MK_TAG(amr_injrIV.s, ANNOTATED_TAG("injr"));
MK_TAG(amr_takeIV.s, ANNOTATED_TAG("take"));
MK_TAG(amr_dropIV.s, ANNOTATED_TAG("drop"));
MK_TAG(amr_idenIV.s, ANNOTATED_TAG("iden"));
MK_TAG(amr_unitIV.s, ANNOTATED_TAG("unit"));
MK_TAG(amr_witnessIV.s, ANNOTATED_TAG("witness"));
MK_TAG(imr_disconnectIV.s, IDENTITY_TAG("disconnect"));
MK_TAG(imr_witnessIV.s, IDENTITY_TAG("witness"));
MK_TAG(identityIV.s, SIMPLICITY_PREFIX "\x1F" "Identity");
MK_TAG(hiddenIV.s, SIMPLICITY_PREFIX "\x1F" "Hidden");
}

/* Given a tag for a node, return the SHA-256 hash of its associated CMR tag.
Expand Down
30 changes: 29 additions & 1 deletion C/jets-secp256k1.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "jets.h"

#include "prefix.h"
#include "sha256.h"
#include "secp256k1/secp256k1_impl.h"
#include "tag.h"

/* Read a secp256k1 field element value from the 'src' frame, advancing the cursor 256 cells.
*
Expand Down Expand Up @@ -582,7 +584,7 @@ bool bip_0340_verify(frameItem* dst, frameItem src, const txEnv* env) {
(void) dst; // dst is unused;
(void) env; // env is unused;

unsigned char buf[64];
unsigned char buf[32];
secp256k1_xonly_pubkey pubkey;
unsigned char msg[32];
unsigned char sig[64];
Expand All @@ -595,3 +597,29 @@ bool bip_0340_verify(frameItem* dst, frameItem src, const txEnv* env) {

return secp256k1_schnorrsig_verify(sig, msg, sizeof(msg), &pubkey);
}

/* check_sig_verify : TWO^256*TWO^512*TWO^512 |- ONE */
bool check_sig_verify(frameItem* dst, frameItem src, const txEnv* env) {
(void) dst; // dst is unused;
(void) env; // env is unused;

unsigned char buf[32];
secp256k1_xonly_pubkey pubkey;
unsigned char msg[64];
unsigned char sig[64];

read8s(buf, 32, &src);
if (!secp256k1_xonly_pubkey_parse(&pubkey, buf)) return false;

{
sha256_midstate output;
sha256_context ctx = MK_TAG(output.s, SIMPLICITY_PREFIX "\x1F" "Signature");
read8s(msg, 64, &src);
sha256_uchars(&ctx, msg, 64);
sha256_finalize(&ctx);
sha256_fromMidstate(buf, output.s);
}

read8s(sig, 64, &src);
return secp256k1_schnorrsig_verify(sig, buf, sizeof(buf), &pubkey);
}
41 changes: 36 additions & 5 deletions C/jets.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,52 @@
#include "jets.h"

/* verify : TWO |- ONE */
bool verify(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
(void) dst; // dst is unused;
return readBit(&src);
}

/* low_32 : ONE |- TWO^32 */
bool low_32(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
(void) src; // env is unused;
(void) src; // src is unused;
write32(dst, 0);
return true;
}

/* one_32 : ONE |- TWO^32 */
bool one_32(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
(void) src; // env is unused;
(void) src; // src is unused;
write32(dst, 1);
return true;
}

/* eq_32 : TWO^32 * TWO^32 |- TWO */
bool eq_32(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
uint_fast32_t x = read32(&src);
uint_fast32_t y = read32(&src);
writeBit(dst, x == y);
return true;
}

/* eq_256 : TWO^256 * TWO^256 |- TWO */
bool eq_256(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
uint32_t arr[16];
read32s(arr, 16, &src);
for (int i = 0; i < 8; ++i) {
if (arr[i] != arr[i+8]) {
writeBit(dst, false);
return true;
}
}
writeBit(dst, true);
return true;
}

bool add_32(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
uint_fast32_t x = read32(&src);
Expand Down Expand Up @@ -84,12 +115,12 @@ bool full_multiply_32(frameItem* dst, frameItem src, const txEnv* env) {
return true;
}

/* eq_32 : TWO^32 * TWO^32 |- TWO */
bool eq_32(frameItem* dst, frameItem src, const txEnv* env) {
/* le_32 : TWO^32 * TWO^32 |- TWO */
bool le_32(frameItem* dst, frameItem src, const txEnv* env) {
(void) env; // env is unused;
uint_fast32_t x = read32(&src);
uint_fast32_t y = read32(&src);
writeBit(dst, x == y);
writeBit(dst, x <= y);
return true;
}

Expand Down
7 changes: 6 additions & 1 deletion C/jets.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ typedef struct txEnv txEnv;
*/
typedef bool (*jet_ptr)(frameItem* dst, frameItem src, const txEnv* env);

bool verify(frameItem* dst, frameItem src, const txEnv* env);
bool low_32(frameItem* dst, frameItem src, const txEnv* env);
bool one_32(frameItem* dst, frameItem src, const txEnv* env);
bool eq_32(frameItem* dst, frameItem src, const txEnv* env);
bool eq_256(frameItem* dst, frameItem src, const txEnv* env);
bool add_32(frameItem* dst, frameItem src, const txEnv* env);
bool full_add_32(frameItem* dst, frameItem src, const txEnv* env);
bool subtract_32(frameItem* dst, frameItem src, const txEnv* env);
bool full_subtract_32(frameItem* dst, frameItem src, const txEnv* env);
bool multiply_32(frameItem* dst, frameItem src, const txEnv* env);
bool full_multiply_32(frameItem* dst, frameItem src, const txEnv* env);
bool eq_32(frameItem* dst, frameItem src, const txEnv* env);
bool le_32(frameItem* dst, frameItem src, const txEnv* env);

bool sha_256_iv(frameItem* dst, frameItem src, const txEnv* env);
bool sha_256_block(frameItem* dst, frameItem src, const txEnv* env);
Expand Down Expand Up @@ -85,6 +88,8 @@ bool linear_combination_1(frameItem* dst, frameItem src, const txEnv* env);
bool linear_verify_1(frameItem* dst, frameItem src, const txEnv* env);
bool decompress(frameItem* dst, frameItem src, const txEnv* env);
bool point_verify_1(frameItem* dst, frameItem src, const txEnv* env);

bool check_sig_verify(frameItem* dst, frameItem src, const txEnv* env);
bool bip_0340_verify(frameItem* dst, frameItem src, const txEnv* env);

bool parse_lock(frameItem* dst, frameItem src, const txEnv* env);
Expand Down
42 changes: 16 additions & 26 deletions C/primitive/elements/checkSigHashAllTx1.c
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
#include "checkSigHashAllTx1.h"

/* A length-prefixed encoding of the following Simplicity program:
* Simplicity.Programs.CheckSigHash.checkSigHash' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
* Simplicity.Programs.CheckSig.Lib.checkSigVerify' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
* (Simplicity.LibSecp256k1.Spec.PubKey 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63)
* (Simplicity.LibSecp256k1.Spec.Sig 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63
* 0xeaefd9fc552f60bc7d3289d95c1cd3da586a815d90878ea482d119cd8b96d80a)
* 0x01dfe15b3bc1ff8534112df200e930d94ccb080b336b267125f8e7683ca3d505)
* with jets.
*/
const unsigned char elementsCheckSigHashAllTx1[] = {
0xe6, 0x7f, 0x18, 0x88, 0x49, 0x02, 0x04, 0x08, 0x10, 0x5c, 0x84, 0x0b, 0x20, 0xae, 0x81, 0x28, 0xa8, 0x5a, 0x02, 0xd0,
0x16, 0xdd, 0x02, 0x68, 0x16, 0x7b, 0x85, 0x02, 0xd7, 0xc0, 0x05, 0xb3, 0x50, 0xa0, 0x58, 0x05, 0xa3, 0x40, 0xb4, 0xee,
0x14, 0x0b, 0x81, 0x70, 0x21, 0x70, 0x20, 0xa8, 0x59, 0x85, 0xc0, 0x02, 0xe1, 0xe1, 0x70, 0x6e, 0x02, 0x2e, 0x00, 0x17,
0x08, 0xe1, 0x02, 0x70, 0xf1, 0x50, 0xb8, 0x6f, 0x06, 0x17, 0x02, 0x0b, 0x84, 0x71, 0x20, 0xb4, 0x05, 0x42, 0xc8, 0x2e,
0x28, 0xe1, 0x82, 0x62, 0x2e, 0x07, 0xc1, 0x85, 0x02, 0xdb, 0xb4, 0x5c, 0x5b, 0xc4, 0xc2, 0x71, 0x00, 0xa8, 0x58, 0x85,
0xa8, 0x2e, 0x07, 0xc0, 0x05, 0xc6, 0x5c, 0x04, 0x50, 0x2e, 0x11, 0xc4, 0x02, 0xe0, 0x9c, 0x42, 0x28, 0x16, 0x01, 0x71,
0x67, 0x0c, 0x17, 0x13, 0x71, 0x18, 0xa0, 0x5c, 0x3f, 0x8b, 0x05, 0xc5, 0x1c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0xe0, 0xc2, 0x81, 0x6d, 0xda, 0x2e, 0x2d, 0xe2, 0x61, 0x38, 0x80, 0x54, 0x2c, 0x42,
0xd4, 0x17, 0x03, 0xe0, 0x02, 0xe3, 0x2e, 0x02, 0x28, 0x17, 0x08, 0xe2, 0x01, 0x70, 0x4e, 0x21, 0x14, 0x0b, 0x00, 0xb8,
0xb3, 0x86, 0x0b, 0x89, 0xb8, 0x8c, 0x50, 0x2e, 0x1f, 0xc5, 0x82, 0xe2, 0x8e, 0x37, 0x14, 0x0b, 0x00, 0xb4, 0x05, 0xc0,
0x02, 0xe2, 0x62, 0x38, 0x38, 0x16, 0x07, 0x14, 0x6c, 0x40, 0x8f, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xed, 0xe3, 0x39, 0x58, 0xfe, 0x26, 0x83, 0xb6, 0x50, 0x53, 0xd6, 0xa8, 0xa2, 0xb4, 0x36, 0x5b,
0x59, 0xe5, 0x7e, 0x71, 0x8c, 0x07, 0x7f, 0x85, 0x6c, 0xef, 0x07, 0xfe, 0x14, 0xd0, 0x44, 0xb7, 0xc8, 0x03, 0xa4, 0xc3,
0x65, 0x33, 0x2c, 0x20, 0x2c, 0xcd, 0xac, 0x99, 0xc4, 0x97, 0xe3, 0x9d, 0xa0, 0xf2, 0x8f, 0x54, 0x14
};

const size_t sizeof_elementsCheckSigHashAllTx1 = sizeof(elementsCheckSigHashAllTx1);

/* The commitment Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
const uint32_t elementsCheckSigHashAllTx1_cmr[] = {
0xd204d59eu, 0x6fcbaba1u, 0xddf35490u, 0x903f293au, 0xea8c18aau, 0x4040114du, 0xbfc45767u, 0xc419c492u
0x82063766u, 0x434f7350u, 0x721de929u, 0x42df5239u, 0x79e3b03eu, 0x0045cee6u, 0x84fefe1au, 0x066ec1f3u
};

/* The identity Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
const uint32_t elementsCheckSigHashAllTx1_imr[] = {
0xce2e963bu, 0x1a489621u, 0xcc1d8b0eu, 0xe364aeb5u, 0xf503fd7fu, 0x06803a12u, 0x8f684091u, 0x250fa4cau
0x653812e3u, 0x41ca0d24u, 0xd04bc716u, 0xd3b33c3fu, 0xbaced1c8u, 0x6a36bfbau, 0xc8a08454u, 0x8d435eeau
};

/* The annotated Merkle root of the above elementsCheckSigHashAllTx1 Simplicity expression. */
const uint32_t elementsCheckSigHashAllTx1_amr[] = {
0xbedaf902u, 0xafdd4a86u, 0xac0fd68du, 0x3c62309du, 0xae081987u, 0x02c438b4u, 0x2cf16263u, 0x8a9ffdb0u
0xeb163ee4u, 0xef1d250cu, 0x1edd44c6u, 0xc59d54dau, 0x24272e48u, 0x5b2bd0a4u, 0x5c619a1bu, 0xe1073c43u
};
4 changes: 2 additions & 2 deletions C/primitive/elements/checkSigHashAllTx1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <stdint.h>

/* A length-prefixed encoding of the following Simplicity program:
* Simplicity.Programs.CheckSigHash.checkSigHash' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
* Simplicity.Programs.CheckSig.Lib.checkSigVerify' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
* (Simplicity.LibSecp256k1.Spec.PubKey 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63)
* (Simplicity.LibSecp256k1.Spec.Sig 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63
* 0xeaefd9fc552f60bc7d3289d95c1cd3da586a815d90878ea482d119cd8b96d80a)
* 0x01dfe15b3bc1ff8534112df200e930d94ccb080b336b267125f8e7683ca3d505)
* with jets.
*/
extern const unsigned char elementsCheckSigHashAllTx1[];
Expand Down
19 changes: 15 additions & 4 deletions C/primitive/elements/primitive.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,21 @@ static int32_t decodePrimitive(jetName* result, bitstream* stream) {
code = decodeUptoMaxInt(stream);
if (code < 0) return code;
switch (code) {
case 1: /* Low */
case 1: /* Verify */
*result = VERIFY; return 0;
case 2: /* Low */
code = decodeUptoMaxInt(stream);
if (code < 0) return code;
switch (code) {
case 5: *result = LOW_32; return 0;
}
break;
case 12: /* Eq */
case 13: /* Eq */
code = decodeUptoMaxInt(stream);
if (code < 0) return code;
switch (code) {
case 5: *result = EQ_32; return 0;
case 8: *result = EQ_256; return 0;
}
break;
}
Expand Down Expand Up @@ -154,6 +157,13 @@ static int32_t decodePrimitive(jetName* result, bitstream* stream) {
case 5: *result = MULTIPLY_32; return 0;
}
break;
case 16: /* Le */
code = decodeUptoMaxInt(stream);
if (code < 0) return code;
switch (code) {
case 5: *result = LE_32; return 0;
}
break;
}
break;
case 3: /* Hash jets chapter */
Expand Down Expand Up @@ -257,7 +267,8 @@ static int32_t decodePrimitive(jetName* result, bitstream* stream) {
code = decodeUptoMaxInt(stream);
if (code < 0) return code;
switch (code) {
case 1: *result = BIP_0340_VERIFY; return 0;
case 1: *result = CHECK_SIG_VERIFY; return 0;
case 2: *result = BIP_0340_VERIFY; return 0;
}
break;
case 7: /* Bitcoin jets chapter */
Expand Down Expand Up @@ -410,7 +421,7 @@ static dag_node jet_node[] = {
static void static_initialize(void) {
{
sha256_midstate jet_iv;
MK_TAG(&jet_iv, JET_TAG);
MK_TAG(jet_iv.s, JET_TAG);

#define MK_JET(name, h0, h1, h2, h3, h4, h5, h6, h7) \
do { \
Expand Down
4 changes: 4 additions & 0 deletions C/primitive/elements/primitiveEnumJet.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CHECK_LOCK_DISTANCE,
CHECK_LOCK_DURATION,
CHECK_LOCK_HEIGHT,
CHECK_LOCK_TIME,
CHECK_SIG_VERIFY,
CURRENT_AMOUNT,
CURRENT_ANNEX_HASH,
CURRENT_ASSET,
Expand All @@ -30,6 +31,7 @@ CURRENT_SCRIPT_HASH,
CURRENT_SCRIPT_SIG_HASH,
CURRENT_SEQUENCE,
DECOMPRESS,
EQ_256,
EQ_32,
FE_ADD,
FE_INVERT,
Expand Down Expand Up @@ -90,6 +92,7 @@ ISSUANCE_TOKEN_AMOUNT,
ISSUANCE_TOKEN_AMOUNTS_HASH,
ISSUANCE_TOKEN_PROOF,
ISSUANCES_HASH,
LE_32,
LINEAR_COMBINATION_1,
LINEAR_VERIFY_1,
LOCK_TIME,
Expand Down Expand Up @@ -157,4 +160,5 @@ TX_LOCK_DISTANCE,
TX_LOCK_DURATION,
TX_LOCK_HEIGHT,
TX_LOCK_TIME,
VERIFY,
VERSION,
1 change: 1 addition & 0 deletions C/primitive/elements/primitiveEnumTy.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ty_pmw2048pmw1024pmw512pmw256pmw128pmw64pmw32pmw16mw8,
ty_pspbw256w256spbw256w64,
ty_ppw256w32w256,
ty_ppw256w512w256,
ty_ppw256w512w512,
ty_ppw256pbw256w256,
ty_ppw256pw512w256w256,
ty_ppw512w256w256,
Expand Down
Loading