Skip to content

Remove intermedite primitive directory #294

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

Merged
merged 1 commit into from
May 16, 2025
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
6 changes: 3 additions & 3 deletions C/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OBJS := bitstream.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o primitive/elements/env.o primitive/elements/exec.o primitive/elements/ops.o primitive/elements/jets.o primitive/elements/primitive.o primitive/elements/cmr.o primitive/elements/txEnv.o
TEST_OBJS := test.o ctx8Pruned.o ctx8Unpruned.o hashBlock.o regression4.o schnorr0.o schnorr6.o typeSkipTest.o primitive/elements/checkSigHashAllTx1.o
OBJS := bitstream.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o elements/env.o elements/exec.o elements/ops.o elements/jets.o elements/primitive.o elements/cmr.o elements/txEnv.o
TEST_OBJS := test.o ctx8Pruned.o ctx8Unpruned.o hashBlock.o regression4.o schnorr0.o schnorr6.o typeSkipTest.o elements/checkSigHashAllTx1.o

# From https://fastcompression.blogspot.com/2019/01/compiler-warnings.html
CWARN := -Werror -Wall -Wextra -Wcast-qual -Wcast-align -Wstrict-aliasing -Wpointer-arith -Winit-self -Wshadow -Wswitch-enum -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wfloat-equal -Wundef -Wconversion
Expand All @@ -14,7 +14,7 @@ CFLAGS := $(CFLAGS) -I include
jets-secp256k1.o: jets-secp256k1.c
$(CC) -c $(CFLAGS) $(CWARN) -Wno-conversion $(CPPFLAGS) -o $@ $<

primitive/elements/jets.o: primitive/elements/jets.c
elements/jets.o: elements/jets.c
$(CC) -c $(CFLAGS) $(CWARN) -Wno-switch-enum -Wswitch $(CPPFLAGS) -o $@ $<

sha256.o: sha256.c
Expand Down
32 changes: 16 additions & 16 deletions C/elements-sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/sha256.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/type.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/typeInference.c

ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/cmr.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/env.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/exec.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/jets.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/ops.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/primitive.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/primitive/elements/txEnv.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/cmr.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/env.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/exec.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/jets.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/ops.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/primitive.c
ELEMENTS_SIMPLICITY_LIB_SOURCES_INT += %reldir%/elements/txEnv.c

ELEMENTS_SIMPLICITY_LIB_HEADERS_INT =
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/bitstream.h
Expand Down Expand Up @@ -89,12 +89,12 @@ ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/secp256k1.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/secp256k1_impl.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/secp256k1/util.h

ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/decodeElementsJets.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/jets.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/ops.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitive.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveEnumJet.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveEnumTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveInitTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/primitiveJetNode.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/primitive/elements/txEnv.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/decodeElementsJets.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/jets.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/ops.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitive.h
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveEnumJet.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveEnumTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveInitTy.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/primitiveJetNode.inc
ELEMENTS_SIMPLICITY_LIB_HEADERS_INT += %reldir%/elements/txEnv.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_CHECKSIGHASHALLTX1_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_CHECKSIGHASHALLTX1_H
#ifndef SIMPLICITY_ELEMENTS_CHECKSIGHASHALLTX1_H
#define SIMPLICITY_ELEMENTS_CHECKSIGHASHALLTX1_H

#include <stddef.h>
#include <stdint.h>
#include "../../bounded.h"
#include "../bounded.h"

/* A length-prefixed encoding of the following Simplicity program:
* Simplicity.Programs.CheckSig.Lib.checkSigVerify' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash
Expand Down
8 changes: 4 additions & 4 deletions C/primitive/elements/cmr.c → C/elements/cmr.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <simplicity/elements/cmr.h>

#include "../../deserialize.h"
#include "../../limitations.h"
#include "../../simplicity_alloc.h"
#include "../../simplicity_assert.h"
#include "../deserialize.h"
#include "../limitations.h"
#include "../simplicity_alloc.h"
#include "../simplicity_assert.h"
#include "primitive.h"

/* Deserialize a Simplicity 'program' and compute its CMR.
Expand Down
8 changes: 4 additions & 4 deletions C/primitive/elements/env.c → C/elements/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <string.h>
#include "txEnv.h"
#include "ops.h"
#include "../../rsort.h"
#include "../../sha256.h"
#include "../../simplicity_assert.h"
#include "../../simplicity_alloc.h"
#include "../rsort.h"
#include "../sha256.h"
#include "../simplicity_assert.h"
#include "../simplicity_alloc.h"

#define PADDING(alignType, allocated) ((alignof(alignType) - (allocated) % alignof(alignType)) % alignof(alignType))

Expand Down
12 changes: 6 additions & 6 deletions C/primitive/elements/exec.c → C/elements/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <string.h>
#include "primitive.h"
#include "txEnv.h"
#include "../../deserialize.h"
#include "../../eval.h"
#include "../../limitations.h"
#include "../../simplicity_alloc.h"
#include "../../simplicity_assert.h"
#include "../../typeInference.h"
#include "../deserialize.h"
#include "../eval.h"
#include "../limitations.h"
#include "../simplicity_alloc.h"
#include "../simplicity_assert.h"
#include "../typeInference.h"

/* Deserialize a Simplicity 'program' with its 'witness' data and execute it in the environment of the 'ix'th input of 'tx' with `taproot`.
*
Expand Down
4 changes: 2 additions & 2 deletions C/primitive/elements/jets.c → C/elements/jets.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "ops.h"
#include "txEnv.h"
#include "../../taptweak.h"
#include "../../simplicity_assert.h"
#include "../taptweak.h"
#include "../simplicity_assert.h"

/* Read a 256-bit hash value from the 'src' frame, advancing the cursor 256 cells.
*
Expand Down
6 changes: 3 additions & 3 deletions C/primitive/elements/jets.h → C/elements/jets.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* This module defines primitives and jets that are specific to the Elements application for Simplicity.
*/
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_JETS_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_JETS_H
#ifndef SIMPLICITY_ELEMENTS_JETS_H
#define SIMPLICITY_ELEMENTS_JETS_H

#include "../../jets.h"
#include "../jets.h"

/* Jets for the Elements application of Simplicity. */
bool simplicity_version(frameItem* dst, frameItem src, const txEnv* env);
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions C/primitive/elements/ops.h → C/elements/ops.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* This module defines operations used in the construction the environment ('txEnv') and some jets.
*/
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_OPS_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_OPS_H
#ifndef SIMPLICITY_ELEMENTS_OPS_H
#define SIMPLICITY_ELEMENTS_OPS_H

#include "../../sha256.h"
#include "../sha256.h"
#include "txEnv.h"

/* Add an 'confidential' value to be consumed by an ongoing SHA-256 evaluation.
Expand Down
8 changes: 4 additions & 4 deletions C/primitive/elements/primitive.c → C/elements/primitive.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "primitive.h"

#include "jets.h"
#include "../../limitations.h"
#include "../../simplicity_alloc.h"
#include "../../simplicity_assert.h"
#include "../limitations.h"
#include "../simplicity_alloc.h"
#include "../simplicity_assert.h"

/* An enumeration of all the types we need to construct to specify the input and output types of all jets created by 'decodeJet'. */
enum TypeNamesForJets {
Expand Down Expand Up @@ -68,7 +68,7 @@ static simplicity_err decodePrimitive(jetName* result, bitstream* stream) {
if (bit < 0) return (simplicity_err)bit;
if (!bit) {
/* Core jets */
#include "../../decodeCoreJets.inc"
#include "../decodeCoreJets.inc"
return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
} else {
/* Elements jets */
Expand Down
8 changes: 4 additions & 4 deletions C/primitive/elements/primitive.h → C/elements/primitive.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Implements the required callbacks for the Elements Simplicity application.
*/
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_PRIMITIVE_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_PRIMITIVE_H
#ifndef SIMPLICITY_ELEMENTS_PRIMITIVE_H
#define SIMPLICITY_ELEMENTS_PRIMITIVE_H

#include "../../bitstream.h"
#include "../../typeInference.h"
#include "../bitstream.h"
#include "../typeInference.h"

/* Allocate a fresh set of unification variables bound to at least all the types necessary
* for all the jets that can be created by 'decodeJet', and also the type 'TWO^256',
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions C/primitive/elements/txEnv.h → C/elements/txEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* It includes the transaction data and input index of the input whose Simplicity program is being executed.
* It also includes the commitment Merkle root of the program being executed.
*/
#ifndef SIMPLICITY_PRIMITIVE_ELEMENTS_TXENV_H
#define SIMPLICITY_PRIMITIVE_ELEMENTS_TXENV_H
#ifndef SIMPLICITY_ELEMENTS_TXENV_H
#define SIMPLICITY_ELEMENTS_TXENV_H

#include <stdbool.h>
#include "../../sha256.h"
#include "../sha256.h"

/* An Elements 'outpoint' consists of a transaction id and output index within that transaction.
* The transaction id can be a either a transaction within the chain, or the transaction id from another chain in case of a peg-in.
Expand Down
4 changes: 2 additions & 2 deletions C/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "typeSkipTest.h"
#include "simplicity_alloc.h"
#include "typeInference.h"
#include "primitive/elements/checkSigHashAllTx1.h"
#include "primitive/elements/primitive.h"
#include "elements/checkSigHashAllTx1.h"
#include "elements/primitive.h"

_Static_assert(CHAR_BIT == 8, "Buffers passed to fmemopen presume 8 bit chars");

Expand Down
2 changes: 1 addition & 1 deletion Haskell-Generate/GenTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ schnorr6 = Example
checkSigHashAllTx1 :: ExampleProg
checkSigHashAllTx1 = Example
{ _name = "checkSigHashAllTx1"
, _path = ["primitive", "elements"]
, _path = ["elements"]
, _text = [ "Simplicity.Programs.CheckSig.Lib.checkSigVerify' Simplicity.Elements.Programs.SigHash.Lib.sigAllHash"
, "(Simplicity.LibSecp256k1.Spec.PubKey 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63)"
, "(Simplicity.LibSecp256k1.Spec.Sig 0x00000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63"
Expand Down
2 changes: 1 addition & 1 deletion Haskell/cbits/elements/env.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "simplicity_alloc.h"
#include "simplicity/elements/env.h"
#include "primitive/elements/txEnv.h"
#include "elements/txEnv.h"

const size_t c_sizeof_rawElementsBuffer = sizeof(rawElementsBuffer);
const size_t c_sizeof_rawElementsOutput = sizeof(rawElementsOutput);
Expand Down
2 changes: 1 addition & 1 deletion Haskell/cbits/elements/jets.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "primitive/elements/jets.h"
#include "elements/jets.h"
#include "../wrappers.h"

WRAP_(version)
Expand Down
6 changes: 3 additions & 3 deletions Simplicity.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ library Simplicity-Indef
vector >=0.12 && <0.14

library
C-sources: C/rsort.c C/primitive/elements/jets.c C/primitive/elements/ops.c C/primitive/elements/env.c
C-sources: C/rsort.c C/elements/jets.c C/elements/ops.c C/elements/env.c
Haskell/cbits/elements/jets.c Haskell/cbits/elements/env.c
Include-dirs: C C/include
Includes: primitive/elements/jets.h primitive/elements/primitive.h simplicity/elements/env.h
Includes: elements/jets.h elements/primitive.h simplicity/elements/env.h
exposed-modules: Simplicity.Bitcoin.Programs.Transaction, Simplicity.Bitcoin.Programs.Transaction.Lib,
Simplicity.Bitcoin.Programs.TimeLock, Simplicity.Elements.Programs.TimeLock,
Simplicity.Elements.Programs.Issuance, Simplicity.Elements.Programs.Issuance.Lib,
Expand Down Expand Up @@ -236,7 +236,7 @@ Test-Suite testsuite
Simplicity.Serialization.Tests,
Simplicity.TestCoreEval,
Simplicity.Ty.Tests
C-sources: C/rsort.c, C/dag.c, C/primitive/elements/primitive.c, C/primitive/elements/txEnv.c, C/bitstream.c
C-sources: C/rsort.c, C/dag.c, C/elements/primitive.c, C/elements/txEnv.c, C/bitstream.c
Haskell/cbits/bitstream.c, Haskell/cbits/dag.c
build-depends: Simplicity,
base >=4.9 && <4.20,
Expand Down
Loading