From 363b4bce148a326e49950b3ac913493e31085e58 Mon Sep 17 00:00:00 2001
From: Alex Shelkovnykov
Date: Sun, 19 Nov 2023 15:30:27 -0500
Subject: [PATCH 1/3] serf: fix bug that would abandon arvo state
---
rust/ares/src/serf.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/rust/ares/src/serf.rs b/rust/ares/src/serf.rs
index b887062..cd455de 100644
--- a/rust/ares/src/serf.rs
+++ b/rust/ares/src/serf.rs
@@ -244,6 +244,7 @@ pub fn serf() -> io::Result<()> {
// XX: Such data should go in the PMA once that's available
unsafe {
let stack = &mut context.nock_context.stack;
+ stack.preserve(&mut context.arvo);
stack.preserve(&mut context.nock_context.cold);
stack.preserve(&mut context.nock_context.warm);
stack.frame_pop();
From ff3a6ebc0d931d7850f81a003617999484aaf94e Mon Sep 17 00:00:00 2001
From: Alex Shelkovnykov
Date: Sun, 19 Nov 2023 15:33:11 -0500
Subject: [PATCH 2/3] jets: remove unnecessary jet check on Nock 2
Nock 2 only comes from Hoon via .*, so we can assume it's never directly
used to invoke jetted code.
---
rust/ares/src/interpreter.rs | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/rust/ares/src/interpreter.rs b/rust/ares/src/interpreter.rs
index 1c24f0e..5a26890 100644
--- a/rust/ares/src/interpreter.rs
+++ b/rust/ares/src/interpreter.rs
@@ -409,26 +409,6 @@ pub fn interpret(context: &mut Context, mut subject: Noun, formula: Noun) -> Res
push_formula(&mut context.stack, vale.formula, false)?;
}
Todo2::ComputeResult => {
- if !cfg!(feature = "sham_hints") {
- if let Some(jet) = context.warm.find_jet(
- &mut context.stack,
- &mut vale.subject,
- &mut res,
- ) {
- match jet(context, vale.subject) {
- Ok(jet_res) => {
- res = jet_res;
- context.stack.pop::();
- continue;
- }
- Err(JetErr::Punt) => {}
- Err(err) => {
- break Err(err.into());
- }
- }
- }
- };
-
let stack = &mut context.stack;
if vale.tail {
stack.pop::();
From 1c2c5d3def9ad1191a3cfd679a0b5d77a400b736 Mon Sep 17 00:00:00 2001
From: Alex Shelkovnykov
Date: Wed, 22 Nov 2023 13:51:04 -0300
Subject: [PATCH 3/3] TEMP
---
.github/workflows/ares-shared.yml | 28 ++
README.md | 7 +
rust/ares/Cargo.lock | 526 +++++++++++++++++++-------
rust/ares/Cargo.toml | 2 +
rust/ares/src/jets.rs | 23 ++
rust/ares/src/jets/hot.rs | 231 +++++++++++
rust/ares/src/jets/lock.rs | 3 +
rust/ares/src/jets/lock/aes.rs | 610 ++++++++++++++++++++++++++++++
rust/ares/src/jets/lock/ed.rs | 252 ++++++++++++
rust/ares/src/jets/lock/sha.rs | 350 +++++++++++++++++
rust/nix/libaes_siv.nix | 17 +
rust/nix/overlay.nix | 4 +
rust/nix/urcrypt.nix | 20 +
rust/shell.nix | 7 +-
14 files changed, 1949 insertions(+), 131 deletions(-)
create mode 100644 rust/ares/src/jets/lock.rs
create mode 100644 rust/ares/src/jets/lock/aes.rs
create mode 100644 rust/ares/src/jets/lock/ed.rs
create mode 100644 rust/ares/src/jets/lock/sha.rs
create mode 100644 rust/nix/libaes_siv.nix
create mode 100644 rust/nix/overlay.nix
create mode 100644 rust/nix/urcrypt.nix
diff --git a/.github/workflows/ares-shared.yml b/.github/workflows/ares-shared.yml
index ac35f4b..bc3546a 100644
--- a/.github/workflows/ares-shared.yml
+++ b/.github/workflows/ares-shared.yml
@@ -22,6 +22,34 @@ jobs:
- name: Format
run: cargo fmt --check
+ # Install third-party dependencies
+ #
+ - name: Install dependencies
+ run: |
+ # install apt packages
+ sudo apt-get install -y \
+ autoconf-archive \
+ libcrypto++-dev \
+ openssl \
+ cmake \
+ libsecp256k1-dev &&
+
+ # install libaes_siv
+ git clone https://github.com/dfoxfranke/libaes_siv.git &&
+ cd libaes_siv &&
+ cmake . &&
+ make &&
+ sudo make install
+
+ # install urcrypt
+ cd .. &&
+ git clone https://github.com/urbit/urcrypt.git &&
+ cd urcrypt &&
+ ./autogen.sh &&
+ ./configure --enable-shared &&
+ make &&
+ sudo make install
+
# See clippy linter docs: https://github.com/rust-lang/rust-clippy
#
# First linter is set to fail for all warnings, then ignored warnings are
diff --git a/README.md b/README.md
index 007e8fd..d0cc2d6 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,10 @@
A redesigned Mars for the Urth/Mars Urbit runtime. Currently WIP.
Read the [proposal](docs/proposal/proposal-nock-performance.md) and [hypotheses](docs/proposal/hypotheses.md) for an overview. Before branching or opening a PR please review the [contribution guidelines](CONTRIBUTING.md).
+
+## Installation
+
+Dependencies:
+* [`libaes_siv`](https://github.com/dfoxfranke/libaes_siv)
+* [`openssl`](https://github.com/openssl/openssl)
+* [`libsecp256k1`](https://github.com/bitcoin-core/secp256k1)
diff --git a/rust/ares/Cargo.lock b/rust/ares/Cargo.lock
index cfa6b4f..7bee7f8 100644
--- a/rust/ares/Cargo.lock
+++ b/rust/ares/Cargo.lock
@@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "aho-corasick"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "anes"
version = "0.1.6"
@@ -14,6 +23,7 @@ version = "0.1.0"
dependencies = [
"ares_macros",
"assert_no_alloc",
+ "autotools",
"bitvec",
"cc",
"criterion",
@@ -29,6 +39,7 @@ dependencies = [
"num-traits",
"signal-hook",
"static_assertions",
+ "urcrypt-sys",
]
[[package]]
@@ -36,7 +47,7 @@ name = "ares_macros"
version = "0.1.0"
dependencies = [
"quote",
- "syn",
+ "syn 1.0.109",
]
[[package]]
@@ -51,7 +62,7 @@ version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
- "hermit-abi 0.1.19",
+ "hermit-abi",
"libc",
"winapi",
]
@@ -62,6 +73,38 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+[[package]]
+name = "autotools"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aef8da1805e028a172334c3b680f93e71126f2327622faef2ec3d893c0a4ad77"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "bindgen"
+version = "0.68.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078"
+dependencies = [
+ "bitflags 2.4.1",
+ "cexpr",
+ "clang-sys",
+ "lazy_static",
+ "lazycell",
+ "log",
+ "peeking_take_while",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash",
+ "shlex",
+ "syn 2.0.39",
+ "which",
+]
+
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -69,10 +112,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
-name = "bitvec"
-version = "1.0.0"
+name = "bitflags"
+version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+
+[[package]]
+name = "bitvec"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
@@ -82,9 +131,9 @@ dependencies = [
[[package]]
name = "bumpalo"
-version = "3.12.0"
+version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
+checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "cast"
@@ -94,9 +143,21 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
-version = "1.0.79"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "cexpr"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+dependencies = [
+ "nom",
+]
[[package]]
name = "cfg-if"
@@ -106,9 +167,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "ciborium"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f"
+checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
dependencies = [
"ciborium-io",
"ciborium-ll",
@@ -117,27 +178,38 @@ dependencies = [
[[package]]
name = "ciborium-io"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369"
+checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
[[package]]
name = "ciborium-ll"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b"
+checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
dependencies = [
"ciborium-io",
"half",
]
[[package]]
-name = "clap"
-version = "3.2.23"
+name = "clang-sys"
+version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
+checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
dependencies = [
- "bitflags",
+ "glob",
+ "libc",
+ "libloading",
+]
+
+[[package]]
+name = "clap"
+version = "3.2.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
+dependencies = [
+ "bitflags 1.3.2",
"clap_lex",
"indexmap",
"textwrap",
@@ -188,21 +260,11 @@ dependencies = [
"itertools",
]
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
-dependencies = [
- "cfg-if",
- "crossbeam-utils",
-]
-
[[package]]
name = "crossbeam-deque"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
+checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
@@ -211,9 +273,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
-version = "0.9.13"
+version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a"
+checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
@@ -224,9 +286,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
-version = "0.8.14"
+version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if",
]
@@ -237,12 +299,28 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
+[[package]]
+name = "errno"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
+[[package]]
+name = "glob"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
+
[[package]]
name = "half"
version = "1.8.2"
@@ -265,12 +343,12 @@ dependencies = [
]
[[package]]
-name = "hermit-abi"
-version = "0.2.6"
+name = "home"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
+checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
- "libc",
+ "windows-sys",
]
[[package]]
@@ -285,9 +363,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "1.9.2"
+version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown",
@@ -310,15 +388,15 @@ dependencies = [
[[package]]
name = "itoa"
-version = "1.0.5"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
+checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "js-sys"
-version = "0.3.60"
+version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
+checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8"
dependencies = [
"wasm-bindgen",
]
@@ -336,19 +414,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
-name = "libc"
-version = "0.2.126"
+name = "lazycell"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
+checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
+
+[[package]]
+name = "libc"
+version = "0.2.150"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
+
+[[package]]
+name = "libloading"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
+dependencies = [
+ "cfg-if",
+ "winapi",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
[[package]]
name = "log"
-version = "0.4.17"
+version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
-dependencies = [
- "cfg-if",
-]
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
+
+[[package]]
+name = "memchr"
+version = "2.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "memmap"
@@ -362,18 +465,34 @@ dependencies = [
[[package]]
name = "memoffset"
-version = "0.7.1"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
+checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
+[[package]]
+name = "minimal-lexical"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
[[package]]
name = "murmur3"
version = "0.5.2"
source = "git+https://github.com/tloncorp/murmur3?rev=7878a0f#7878a0fbecf465720891b625f1a1fc3e19b6a960"
+[[package]]
+name = "nom"
+version = "7.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
+dependencies = [
+ "memchr",
+ "minimal-lexical",
+]
+
[[package]]
name = "num-derive"
version = "0.3.3"
@@ -382,33 +501,23 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.109",
]
[[package]]
name = "num-traits"
-version = "0.2.16"
+version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
+checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
-[[package]]
-name = "num_cpus"
-version = "1.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
-dependencies = [
- "hermit-abi 0.2.6",
- "libc",
-]
-
[[package]]
name = "once_cell"
-version = "1.17.0"
+version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oorandom"
@@ -418,15 +527,27 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "os_str_bytes"
-version = "6.4.1"
+version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
+checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
+
+[[package]]
+name = "peeking_take_while"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "plotters"
-version = "0.3.4"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97"
+checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45"
dependencies = [
"num-traits",
"plotters-backend",
@@ -437,33 +558,43 @@ dependencies = [
[[package]]
name = "plotters-backend"
-version = "0.3.4"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
+checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609"
[[package]]
name = "plotters-svg"
-version = "0.3.3"
+version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f"
+checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab"
dependencies = [
"plotters-backend",
]
[[package]]
-name = "proc-macro2"
-version = "1.0.40"
+name = "prettyplease"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
+checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"
+dependencies = [
+ "proc-macro2",
+ "syn 2.0.39",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.20"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@@ -491,9 +622,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
[[package]]
name = "rayon"
-version = "1.6.1"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7"
+checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
@@ -501,36 +632,67 @@ dependencies = [
[[package]]
name = "rayon-core"
-version = "1.10.2"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b"
+checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
- "crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
- "num_cpus",
]
[[package]]
name = "regex"
-version = "1.7.1"
+version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
+dependencies = [
+ "aho-corasick",
+ "memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
-version = "0.6.28"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
+
+[[package]]
+name = "rustc-hash"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+
+[[package]]
+name = "rustix"
+version = "0.38.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
+dependencies = [
+ "bitflags 2.4.1",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
[[package]]
name = "ryu"
-version = "1.0.12"
+version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
+checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "same-file"
@@ -543,41 +705,47 @@ dependencies = [
[[package]]
name = "scopeguard"
-version = "1.1.0"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
-version = "1.0.147"
+version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
+checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.147"
+version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
+checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.39",
]
[[package]]
name = "serde_json"
-version = "1.0.91"
+version = "1.0.108"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
+checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
dependencies = [
"itoa",
"ryu",
"serde",
]
+[[package]]
+name = "shlex"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
+
[[package]]
name = "signal-hook"
version = "0.3.17"
@@ -605,9 +773,20 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
-version = "1.0.98"
+version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
dependencies = [
"proc-macro2",
"quote",
@@ -638,26 +817,35 @@ dependencies = [
[[package]]
name = "unicode-ident"
-version = "1.0.1"
+version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[package]]
+name = "urcrypt-sys"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ced751f95a527a3458eb67c75e4ae7093d41585edaa7565f5769101502473019"
+dependencies = [
+ "bindgen",
+ "pkg-config",
+]
[[package]]
name = "walkdir"
-version = "2.3.2"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
+checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
dependencies = [
"same-file",
- "winapi",
"winapi-util",
]
[[package]]
name = "wasm-bindgen"
-version = "0.2.83"
+version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
+checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@@ -665,24 +853,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.83"
+version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
+checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.39",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.83"
+version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
+checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -690,33 +878,45 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.83"
+version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
+checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.39",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.83"
+version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
+checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b"
[[package]]
name = "web-sys"
-version = "0.3.60"
+version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
+checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85"
dependencies = [
"js-sys",
"wasm-bindgen",
]
+[[package]]
+name = "which"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
+dependencies = [
+ "either",
+ "home",
+ "once_cell",
+ "rustix",
+]
+
[[package]]
name = "winapi"
version = "0.3.9"
@@ -735,9 +935,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
-version = "0.1.5"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
@@ -749,10 +949,76 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
-name = "wyz"
-version = "0.5.0"
+name = "windows-sys"
+version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "wyz"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
diff --git a/rust/ares/Cargo.toml b/rust/ares/Cargo.toml
index ea0f734..27d1199 100644
--- a/rust/ares/Cargo.toml
+++ b/rust/ares/Cargo.toml
@@ -29,8 +29,10 @@ num-derive = "0.3"
num-traits = "0.2"
signal-hook = "0.3"
static_assertions = "1.1.0"
+urcrypt-sys = "0.1.1"
[build-dependencies]
+autotools = "0.2.6"
cc = "1.0.79"
[[bin]]
diff --git a/rust/ares/src/jets.rs b/rust/ares/src/jets.rs
index 8c31292..f2bc319 100644
--- a/rust/ares/src/jets.rs
+++ b/rust/ares/src/jets.rs
@@ -6,6 +6,7 @@ pub mod bits;
pub mod form;
pub mod hash;
pub mod list;
+pub mod lock;
pub mod lute;
pub mod math;
pub mod nock;
@@ -26,6 +27,9 @@ use crate::jets::nock::*;
use crate::jets::serial::*;
use crate::jets::sort::*;
+use crate::jets::lock::aes::*;
+use crate::jets::lock::ed::*;
+use crate::jets::lock::sha::*;
use crate::jets::tree::*;
use crate::jets::warm::Warm;
use crate::mem::NockStack;
@@ -121,9 +125,28 @@ pub fn get_jet(jet_name: Noun) -> Option {
tas!(b"cue") => Some(jet_cue),
tas!(b"jam") => Some(jet_jam),
//
+ tas!(b"shas") => Some(jet_shas),
+ tas!(b"shax") => Some(jet_shax),
+ tas!(b"shay") => Some(jet_shay),
+ tas!(b"shal") => Some(jet_shal),
+ tas!(b"sha1") => Some(jet_sha1),
+ //
tas!(b"scow") => Some(jet_scow),
//
tas!(b"mink") => Some(jet_mink),
+ //
+ tas!(b"puck") => Some(jet_puck),
+ tas!(b"shar") => Some(jet_shar),
+ tas!(b"sign") => Some(jet_sign),
+ tas!(b"veri") => Some(jet_veri),
+ //
+ tas!(b"siva_en") => Some(jet_siva_en),
+ tas!(b"siva_de") => Some(jet_siva_de),
+ tas!(b"sivb_en") => Some(jet_sivb_en),
+ tas!(b"sivb_de") => Some(jet_sivb_de),
+ tas!(b"sivc_en") => Some(jet_sivc_en),
+ tas!(b"sivc_de") => Some(jet_sivc_de),
+ //
_ => {
// eprintln!("Unknown jet: {:?}", jet_name);
None
diff --git a/rust/ares/src/jets/hot.rs b/rust/ares/src/jets/hot.rs
index bc2d564..379aacd 100644
--- a/rust/ares/src/jets/hot.rs
+++ b/rust/ares/src/jets/hot.rs
@@ -208,6 +208,67 @@ const TRUE_HOT_STATE: &[(&[Either<&[u8], (u64, u64)>], u64, Jet)] = &[
jet_jam,
),
//
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"shas"),
+ ],
+ 1,
+ jet_shas,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"shax"),
+ ],
+ 1,
+ jet_shax,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"shay"),
+ ],
+ 1,
+ jet_shay,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"shal"),
+ ],
+ 1,
+ jet_shal,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"sha"),
+ Left(b"sha1"),
+ ],
+ 1,
+ jet_sha1,
+ ),
+ //
(
&[
K_139,
@@ -358,6 +419,176 @@ const TRUE_HOT_STATE: &[(&[Either<&[u8], (u64, u64)>], u64, Jet)] = &[
1,
jet_ut_rest,
),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"coed"),
+ Left(b"ed"),
+ Left(b"puck"),
+ ],
+ 1,
+ jet_puck,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"coed"),
+ Left(b"ed"),
+ Left(b"shar"),
+ ],
+ 1,
+ jet_shar,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"coed"),
+ Left(b"ed"),
+ Left(b"sign"),
+ ],
+ 1,
+ jet_sign,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"coed"),
+ Left(b"ed"),
+ Left(b"veri"),
+ ],
+ 1,
+ jet_veri,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"siva"),
+ Left(b"en"),
+ ],
+ 1,
+ jet_siva_en,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"siva"),
+ Left(b"de"),
+ ],
+ 1,
+ jet_siva_de,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"sivb"),
+ Left(b"en"),
+ ],
+ 1,
+ jet_sivb_en,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"sivb"),
+ Left(b"de"),
+ ],
+ 1,
+ jet_sivb_de,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"sivc"),
+ Left(b"en"),
+ ],
+ 1,
+ jet_sivc_en,
+ ),
+ //
+ (
+ &[
+ K_139,
+ Left(b"one"),
+ Left(b"two"),
+ Left(b"tri"),
+ Left(b"qua"),
+ Left(b"pen"),
+ Left(b"hex"),
+ Left(b"aes"),
+ Left(b"sivc"),
+ Left(b"de"),
+ ],
+ 1,
+ jet_sivc_de,
+ ),
];
#[derive(Copy, Clone)]
diff --git a/rust/ares/src/jets/lock.rs b/rust/ares/src/jets/lock.rs
new file mode 100644
index 0000000..1604899
--- /dev/null
+++ b/rust/ares/src/jets/lock.rs
@@ -0,0 +1,3 @@
+pub mod aes;
+pub mod ed;
+pub mod sha;
diff --git a/rust/ares/src/jets/lock/aes.rs b/rust/ares/src/jets/lock/aes.rs
new file mode 100644
index 0000000..1297d7d
--- /dev/null
+++ b/rust/ares/src/jets/lock/aes.rs
@@ -0,0 +1,610 @@
+use crate::interpreter::Context;
+use crate::jets::bits::util::met;
+use crate::jets::util::slot;
+use crate::jets::{Error, JetErr, Result};
+use crate::noun::{IndirectAtom, Noun, D};
+use urcrypt_sys::*;
+
+crate::gdb!();
+
+pub fn jet_siva_en(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let txt = slot(subject, 6)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let atoms = slot(subject, 61)?;
+
+ if (met(3, key) as usize) > 32 {
+ // XX vere punts; we should do the same in the future
+ Err(JetErr::Punt)
+ } else {
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_en(
+ stack,
+ key_bytes,
+ atoms,
+ txt,
+ urcrypt_aes_siva_en,
+ ))
+ }
+ }
+}
+
+pub fn jet_siva_de(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let iv = slot(subject, 12)?.as_atom()?;
+ let len = slot(subject, 26)?.as_atom()?;
+ let txt = slot(subject, 27)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let ads = slot(subject, 61)?;
+
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_de(
+ stack,
+ key_bytes,
+ ads,
+ iv,
+ len,
+ txt,
+ urcrypt_aes_siva_de,
+ ))
+ }
+}
+
+pub fn jet_sivb_en(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let txt = slot(subject, 6)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let atoms = slot(subject, 61)?;
+
+ if (met(3, key) as usize) > 48 {
+ // XX vere punts; we should do the same in the future
+ Err(JetErr::Fail(Error::NonDeterministic(D(0))))
+ } else {
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 48);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_en(
+ stack,
+ key_bytes,
+ atoms,
+ txt,
+ urcrypt_aes_sivb_en,
+ ))
+ }
+ }
+}
+
+pub fn jet_sivb_de(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let iv = slot(subject, 12)?.as_atom()?;
+ let len = slot(subject, 26)?.as_atom()?;
+ let txt = slot(subject, 27)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let ads = slot(subject, 61)?;
+
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 48);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_de(
+ stack,
+ key_bytes,
+ ads,
+ iv,
+ len,
+ txt,
+ urcrypt_aes_sivb_de,
+ ))
+ }
+}
+
+pub fn jet_sivc_en(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let txt = slot(subject, 6)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let atoms = slot(subject, 61)?;
+
+ if (met(3, key) as usize) > 64 {
+ // XX vere punts; we should do the same in the future
+ Err(JetErr::Punt)
+ } else {
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 64);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_en(
+ stack,
+ key_bytes,
+ atoms,
+ txt,
+ urcrypt_aes_sivc_en,
+ ))
+ }
+ }
+}
+
+pub fn jet_sivc_de(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let iv = slot(subject, 12)?.as_atom()?;
+ let len = slot(subject, 26)?.as_atom()?;
+ let txt = slot(subject, 27)?.as_atom()?;
+ let key = slot(subject, 60)?.as_atom()?;
+ let ads = slot(subject, 61)?;
+
+ unsafe {
+ let (mut _key_ida, key_bytes) = IndirectAtom::new_raw_mut_bytes(stack, 64);
+ key_bytes[0..key.as_bytes().len()].copy_from_slice(key.as_bytes());
+
+ Ok(util::_siv_de(
+ stack,
+ key_bytes,
+ ads,
+ iv,
+ len,
+ txt,
+ urcrypt_aes_sivc_de,
+ ))
+ }
+}
+
+mod util {
+ use crate::jets::bits::util::met;
+ use crate::mem::NockStack;
+ use crate::noun::{Atom, IndirectAtom, Noun, D, T};
+ use std::ptr::null_mut;
+ use urcrypt_sys::urcrypt_aes_siv_data;
+
+ type UrcryptSiv = unsafe extern "C" fn(
+ *mut u8,
+ usize,
+ *mut urcrypt_aes_siv_data,
+ usize,
+ *mut u8,
+ *mut u8,
+ *mut u8,
+ ) -> i32;
+
+ /// Returns a tuple of (length, bytes, size):
+ /// * length: number of items in the list of atoms
+ /// * bytes: size in bytes of the associative array
+ /// * size: size of allocation (array + atom storage)
+ ///
+ /// # Arguments
+ ///
+ /// * `atoms` - the list of atoms to measure
+ ///
+ pub fn _measure_atoms(atoms: Noun) -> (usize, usize, usize) {
+ let length;
+ let bytes;
+ let size;
+
+ let mut tail = atoms;
+ let mut a = 0;
+ let mut b = 0;
+ unsafe {
+ loop {
+ if tail.raw_equals(D(0)) {
+ break;
+ }
+ let (head, ttail) = match tail.as_cell() {
+ Ok(cell) => (cell.head(), cell.tail()),
+ Err(_) => panic!("_measure_atoms: not a cell"),
+ };
+ let head = match head.as_atom() {
+ Ok(a) => a,
+ Err(_) => panic!("_measure_atoms: head not an atom"),
+ };
+ tail = ttail;
+
+ let tmp = b;
+ b += met(3, head);
+ // could be just asserting that met returns more than 0
+ if b < tmp {
+ panic!("_measure_atoms: overflow");
+ }
+ a += 1;
+ }
+
+ // check for size overflows
+ let tmp = a * std::mem::size_of::();
+ size = tmp + b;
+ if (tmp / a) != std::mem::size_of::() {
+ panic!("_measure_atoms: wrong size")
+ } else if size < tmp {
+ panic!("_measure_atoms: overflow")
+ } else {
+ length = a;
+ bytes = tmp;
+ }
+
+ (length, bytes, size)
+ }
+ }
+
+ /// Encodes the list of atoms. Assumes atoms is a
+ /// valid list of atoms, as it's already been measured.
+ ///
+ /// # Arguments
+ ///
+ /// * `atoms` - the list of atoms to allocate
+ /// * `bytes` - the encoding size
+ /// * `data` - the data allocation
+ ///
+ pub fn _encode_atoms(atoms: Noun, data: &mut [urcrypt_aes_siv_data]) {
+ let mut t = atoms;
+ let mut i = 0;
+ unsafe {
+ while !t.raw_equals(D(0)) {
+ let (head, tail) = match t.as_cell() {
+ Ok(cell) => (cell.head(), cell.tail()),
+ Err(_) => panic!("_encode_atoms: not a cell"),
+ };
+ let head = match head.as_atom() {
+ Ok(a) => a,
+ Err(_) => panic!("_encode_atoms: head not an atom"),
+ };
+ t = tail;
+ let head_bytes = head.as_bytes();
+ data[i].length = head_bytes.len();
+ // allocate enough bytes at data[i].bytes
+ let ptr = std::alloc::alloc(
+ std::alloc::Layout::from_size_align(head_bytes.len(), 8).unwrap(),
+ );
+ // copy the bytes from head_bytes into the buffer pointed to by data[i].bytes (which is a *mut u8)
+ let data_bytes: &mut [u8] = std::slice::from_raw_parts_mut(ptr, head_bytes.len());
+ data_bytes.copy_from_slice(head_bytes);
+ data[i].bytes = data_bytes.as_mut_ptr();
+ i += 1;
+ }
+ }
+ }
+
+ pub fn _allocate_atoms(atoms: Noun) -> &'static mut [urcrypt_aes_siv_data] {
+ if unsafe { atoms.raw_equals(D(0)) } {
+ return &mut [];
+ }
+ let (length, _, size) = _measure_atoms(atoms);
+ let siv_data: &mut [urcrypt_aes_siv_data] = unsafe {
+ let ptr = std::alloc::alloc(std::alloc::Layout::from_size_align(size, 8).unwrap());
+ std::slice::from_raw_parts_mut(ptr as *mut urcrypt_aes_siv_data, length)
+ };
+ _encode_atoms(atoms, siv_data);
+ siv_data
+ }
+
+ pub fn _siv_en(
+ stack: &mut NockStack,
+ key: &mut [u8],
+ ads: Noun,
+ txt: Atom,
+ fun: UrcryptSiv,
+ ) -> Noun {
+ let siv_data = _allocate_atoms(ads);
+
+ let txt_len = met(3, txt);
+ let (_txt_atom, txt_bytes) = match txt_len {
+ 0 => (D(0), &mut [] as &mut [u8]),
+ _ => {
+ let (mut txt_ida, txt_bytes) =
+ unsafe { IndirectAtom::new_raw_mut_bytes(stack, txt_len) };
+ txt_bytes[0..txt_len].copy_from_slice(&(txt.as_bytes()[0..txt_len]));
+ (unsafe { txt_ida.normalize_as_atom().as_noun() }, txt_bytes)
+ }
+ };
+
+ let (mut iv, iv_bytes) = unsafe { IndirectAtom::new_raw_mut_bytes(stack, 16) };
+ let (out_atom, out_bytes) = match txt_len {
+ 0 => (D(0), &mut [] as &mut [u8]),
+ _ => unsafe {
+ let (out_ida, out_bytes) = IndirectAtom::new_raw_mut_bytes(stack, txt_len);
+ (out_ida.as_noun(), out_bytes)
+ },
+ };
+
+ unsafe {
+ fun(
+ if txt_len == 0 {
+ null_mut::()
+ } else {
+ txt_bytes.as_mut_ptr()
+ },
+ txt_len,
+ siv_data.as_mut_ptr(),
+ siv_data.len(),
+ key.as_mut_ptr(),
+ iv_bytes.as_mut_ptr(),
+ out_bytes.as_mut_ptr(),
+ );
+ }
+
+ T(
+ stack,
+ &[
+ unsafe { iv.normalize_as_atom().as_noun() },
+ D(txt_len as u64),
+ out_atom,
+ ],
+ )
+ }
+
+ pub fn _siv_de(
+ stack: &mut NockStack,
+ key: &mut [u8],
+ ads: Noun,
+ iv: Atom,
+ len: Atom,
+ txt: Atom,
+ fun: UrcryptSiv,
+ ) -> Noun {
+ let siv_data = _allocate_atoms(ads);
+
+ let (_iv_ida, iv_bytes) = unsafe { IndirectAtom::new_raw_mut_bytes(stack, 16) };
+ iv_bytes[0..16].copy_from_slice(&(iv.as_bytes()[0..16]));
+
+ let txt_len = if met(5, len) > 1 {
+ 0
+ } else {
+ let len_bytes = len.as_bytes();
+ len_bytes[0] as usize // XX this might be wrong
+ };
+ // XX vere bail:fails on txt_len == 0
+ let (_txt_ida, txt_bytes) = unsafe { IndirectAtom::new_raw_mut_bytes(stack, txt_len) };
+ txt_bytes[0..txt_len].copy_from_slice(&(txt.as_bytes()[0..txt_len]));
+
+ let (out_atom, out_bytes) = match txt_len {
+ 0 => (D(0), &mut [] as &mut [u8]),
+ _ => unsafe {
+ let (out_ida, out_bytes) = IndirectAtom::new_raw_mut_bytes(stack, txt_len);
+ (out_ida.as_noun(), out_bytes)
+ },
+ };
+
+ unsafe {
+ fun(
+ if txt_len == 0 {
+ null_mut::()
+ } else {
+ txt_bytes.as_mut_ptr()
+ },
+ txt_len,
+ siv_data.as_mut_ptr(),
+ siv_data.len(),
+ key.as_mut_ptr(),
+ iv_bytes.as_mut_ptr(),
+ out_bytes.as_mut_ptr(),
+ );
+ }
+
+ T(stack, &[D(0), out_atom])
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::jets::util::test::{assert_noun_eq, init_context, A};
+ use crate::jets::Jet;
+ use crate::mem::NockStack;
+ use crate::noun::{Cell, D, T};
+ use ibig::ubig;
+
+ pub fn assert_jet_in_door(
+ c: &mut Context,
+ jet: Jet,
+ sam: &[fn(&mut NockStack) -> Noun], // regular sample
+ ctx: &[fn(&mut NockStack) -> Noun], // door sample as context
+ res: Noun,
+ ) {
+ let sam: Vec = sam.iter().map(|f| f(&mut c.stack)).collect();
+ let ctx: Vec = ctx.iter().map(|f| f(&mut c.stack)).collect();
+ let sam = if sam.len() > 1 {
+ T(&mut c.stack, &sam)
+ } else {
+ sam[0]
+ };
+ let ctx = if ctx.len() > 1 {
+ T(&mut c.stack, &ctx)
+ } else {
+ ctx[0]
+ };
+ let pay = Cell::new(&mut c.stack, sam, ctx).as_noun();
+ let sbj = Cell::new(&mut c.stack, D(0), pay).as_noun();
+ // std::io::stderr().flush().unwrap();
+ let jet_res = jet(c, sbj).unwrap();
+ // std::io::stderr().flush().unwrap();
+ assert_noun_eq(&mut c.stack, jet_res, res);
+ }
+
+ #[test]
+ pub fn test_siva_en() {
+ let c = &mut init_context();
+ /*
+ > (~(en siva:aes:crypto [key=0x0 vec=~]) txt=0x0)
+ [p=0xb0f7.a0df.be76.c85b.5e29.bb31.aaec.fc77 q=0 r=0x0]
+ */
+ fn sample(_s: &mut NockStack) -> Noun {
+ D(0)
+ }
+ fn context(s: &mut NockStack) -> Noun {
+ let sample = T(s, &[D(0), D(0)]);
+ T(s, &[D(0), sample, D(0)])
+ }
+
+ let siv = A(&mut c.stack, &ubig!(0xb0f7a0dfbe76c85b5e29bb31aaecfc77));
+ let res = T(&mut c.stack, &[siv, D(0), D(0x0)]);
+ assert_jet_in_door(c, jet_siva_en, &[sample], &[context], res);
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ A(s, &ubig!(0x112233445566778899aabbccddee))
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(
+ s,
+ &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff),
+ );
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let iv = A(&mut c.stack, &ubig!(0x85632d07c6e8f37f950acd320a2ecc93));
+ let len = D(14);
+ let cyp = A(&mut c.stack, &ubig!(0x40c02b9690c4dc04daef7f6afe5c));
+ let res = T(&mut c.stack, &[iv, len, cyp]);
+ assert_jet_in_door(c, jet_siva_en, &[gate_sample], &[gate_context], res);
+ }
+
+ #[test]
+ pub fn test_sivb_en() {
+ let c = &mut init_context();
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ A(s, &ubig!(0x112233445566778899aabbccddee))
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(s, &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff00112233445566778899aabbccddeeff));
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let iv = A(&mut c.stack, &ubig!(0x89e869b93256785154f0963962fe0740));
+ let len = D(14);
+ let cyp = A(&mut c.stack, &ubig!(0xf313e667b56478a032b9913e923c));
+ let res = T(&mut c.stack, &[iv, len, cyp]);
+ assert_jet_in_door(c, jet_sivb_en, &[gate_sample], &[gate_context], res);
+ }
+
+ #[test]
+ pub fn test_sivc_en() {
+ let c = &mut init_context();
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ A(s, &ubig!(0x112233445566778899aabbccddee))
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(s, &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff));
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let iv = A(&mut c.stack, &ubig!(0x724dfb2eaf94dbb19b0ba3a299a0801e));
+ let len = D(14);
+ let cyp = A(&mut c.stack, &ubig!(0x1206291a35ad3db0212773440fd0));
+ let res = T(&mut c.stack, &[iv, len, cyp]);
+ assert_jet_in_door(c, jet_sivc_en, &[gate_sample], &[gate_context], res);
+ }
+
+ #[test]
+ pub fn test_siva_de() {
+ let c = &mut init_context();
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ let iv = A(s, &ubig!(0x85632d07c6e8f37f950acd320a2ecc93));
+ let len = D(14);
+ let cyp = A(s, &ubig!(0x40c02b9690c4dc04daef7f6afe5c));
+ T(s, &[iv, len, cyp])
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(
+ s,
+ &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff),
+ );
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let txt = A(&mut c.stack, &ubig!(0x112233445566778899aabbccddee));
+ let res = T(&mut c.stack, &[D(0), txt]);
+ assert_jet_in_door(c, jet_siva_de, &[gate_sample], &[gate_context], res);
+ }
+
+ #[test]
+ pub fn test_sivb_de() {
+ let c = &mut init_context();
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ let iv = A(s, &ubig!(0x89e869b93256785154f0963962fe0740));
+ let len = D(14);
+ let cyp = A(s, &ubig!(0xf313e667b56478a032b9913e923c));
+ T(s, &[iv, len, cyp])
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(s, &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff00112233445566778899aabbccddeeff));
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let txt = A(&mut c.stack, &ubig!(0x112233445566778899aabbccddee));
+ let res = T(&mut c.stack, &[D(0), txt]);
+ assert_jet_in_door(c, jet_sivb_de, &[gate_sample], &[gate_context], res);
+ }
+
+ #[test]
+ pub fn test_sivc_de() {
+ let c = &mut init_context();
+
+ /* RFC 5297
+ * https://datatracker.ietf.org/doc/html/rfc5297#appendix-A
+ */
+ fn gate_sample(s: &mut NockStack) -> Noun {
+ let iv = A(s, &ubig!(0x724dfb2eaf94dbb19b0ba3a299a0801e));
+ let len = D(14);
+ let cyp = A(s, &ubig!(0x1206291a35ad3db0212773440fd0));
+ T(s, &[iv, len, cyp])
+ }
+ fn gate_context(s: &mut NockStack) -> Noun {
+ let key = A(s, &ubig!(_0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff));
+ let a = A(
+ s,
+ &ubig!(_0x101112131415161718191a1b1c1d1e1f2021222324252627),
+ );
+ let vec = T(s, &[a, D(0)]);
+ let sample = T(s, &[key, vec]);
+ T(s, &[D(0), sample, D(0)])
+ }
+ let txt = A(&mut c.stack, &ubig!(0x112233445566778899aabbccddee));
+ let res = T(&mut c.stack, &[D(0), txt]);
+ assert_jet_in_door(c, jet_sivc_de, &[gate_sample], &[gate_context], res);
+ }
+}
diff --git a/rust/ares/src/jets/lock/ed.rs b/rust/ares/src/jets/lock/ed.rs
new file mode 100644
index 0000000..49c6795
--- /dev/null
+++ b/rust/ares/src/jets/lock/ed.rs
@@ -0,0 +1,252 @@
+use crate::interpreter::{Context, Error};
+use crate::jets::bits::util::met;
+use crate::jets::util::slot;
+use crate::jets::{JetErr, Result};
+use crate::noun::{IndirectAtom, Noun, D, NO, YES};
+use urcrypt_sys::*;
+
+crate::gdb!();
+
+pub fn jet_puck(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sed = slot(subject, 6)?.as_direct()?;
+
+ if sed.bit_size() > 32 {
+ return Err(JetErr::Fail(Error::Deterministic(D(0))));
+ }
+
+ unsafe {
+ let (mut _seed_ida, seed) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ let sed_bytes = sed.data().to_le_bytes();
+ seed[0..sed_bytes.len()].copy_from_slice(&sed_bytes[..]);
+
+ let (mut pub_ida, pub_key) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ urcrypt_ed_puck(seed.as_ptr(), pub_key.as_mut_ptr());
+
+ Ok(pub_ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_shar(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let pub_key = slot(subject, 12)?.as_direct()?;
+ let sec_key = slot(subject, 13)?.as_direct()?;
+
+ if sec_key.bit_size() > 32 {
+ return Err(JetErr::Fail(Error::Deterministic(D(0))));
+ }
+ if pub_key.bit_size() > 32 {
+ // vere punts; we should do the same in the future
+ return Err(JetErr::Punt);
+ }
+
+ unsafe {
+ let (_, public) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ let (_, secret) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+
+ let pub_bytes = pub_key.data().to_le_bytes();
+ let sec_bytes = sec_key.data().to_le_bytes();
+
+ public[0..pub_bytes.len()].copy_from_slice(&pub_bytes[..]);
+ secret[0..sec_bytes.len()].copy_from_slice(&sec_bytes[..]);
+
+ let (mut shar_ida, shar) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ urcrypt_ed_shar(public.as_ptr(), secret.as_ptr(), shar.as_mut_ptr());
+
+ Ok(shar_ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_sign(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let msg = slot(sam, 2)?.as_atom()?;
+ let sed = slot(sam, 3)?.as_atom()?;
+
+ unsafe {
+ let sed_bytes = sed.as_bytes();
+ if sed_bytes.len() > 32 {
+ return Err(JetErr::Fail(Error::Deterministic(D(0))));
+ };
+
+ let msg_bytes = &(msg.as_bytes())[0..met(3, msg)]; // drop trailing zeros
+
+ let (mut _seed_ida, seed) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ seed.copy_from_slice(sed_bytes);
+
+ let (mut sig_ida, sig) = IndirectAtom::new_raw_mut_bytes(stack, 64);
+ urcrypt_ed_sign(
+ msg_bytes.as_ptr(),
+ msg_bytes.len(),
+ seed.as_ptr(),
+ sig.as_mut_ptr(),
+ );
+ sig.reverse(); // LSB first
+
+ Ok(sig_ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_veri(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sig = slot(subject, 12)?.as_atom()?;
+ let msg = slot(subject, 26)?.as_atom()?;
+ let puk = slot(subject, 27)?.as_atom()?;
+
+ unsafe {
+ let sig_bytes = sig.as_bytes();
+ // vere punts; we should do the same in the future
+ if sig_bytes.len() > 64 {
+ return Err(JetErr::Punt);
+ };
+
+ let pub_bytes = puk.as_bytes();
+ // vere punts; we should do the same in the future
+ if pub_bytes.len() > 32 {
+ return Err(JetErr::Punt);
+ };
+
+ let (mut _sig_ida, signature) = IndirectAtom::new_raw_mut_bytes(stack, 64);
+ signature.copy_from_slice(sig_bytes);
+ let (mut _pub_ida, public_key) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ public_key.copy_from_slice(pub_bytes);
+
+ let message = &(msg.as_bytes())[0..met(3, msg)]; // drop trailing zeros
+
+ let valid = urcrypt_ed_veri(
+ message.as_ptr(),
+ message.len(),
+ public_key.as_ptr(),
+ signature.as_ptr(),
+ );
+
+ Ok(if valid { YES } else { NO })
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::jets::util::test::{assert_jet, assert_jet_err, init_context, A};
+ use crate::noun::{D, T};
+ use ibig::ubig;
+
+ #[test]
+ fn test_puck() {
+ let c = &mut init_context();
+
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0xfb099b0acc4d1ce37f9982a2ed331245e0cdfdf6979364b7676a142b8233e53b),
+ );
+ assert_jet(c, jet_puck, D(32), ret);
+
+ let sam = A(
+ &mut c.stack,
+ &ubig!(_0xfb099b0acc4d1ce37f9982a2ed331245e0cdfdf6979364b7676a142b8233e53b),
+ );
+ assert_jet_err(c, jet_puck, sam, JetErr::Fail(Error::Deterministic(D(0))));
+ }
+
+ #[test]
+ fn test_shar() {
+ let c = &mut init_context();
+
+ let sam = T(&mut c.stack, &[D(234), D(234)]);
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0x6ecd5779a47841207a2cd0c9d085796aa646842885a332adac540027d768c1c5),
+ );
+ assert_jet(c, jet_shar, sam, ret);
+
+ let sam = A(
+ &mut c.stack,
+ &ubig!(_0xfb099b0acc4d1ce37f9982a2ed331245e0cdfdf6979364b7676a142b8233e53b),
+ );
+ assert_jet_err(c, jet_shar, sam, JetErr::Fail(Error::Deterministic(D(0))));
+ }
+
+ #[test]
+ fn test_sign() {
+ let c = &mut init_context();
+
+ unsafe {
+ let message = D(0x72);
+
+ let sed_ubig =
+ ubig!(_0x4ccd089b28ff96da9db6c346ec114e0f5b8a319f35aba624da8cf6ed4fb8a6fb);
+ let sed_bytes = sed_ubig.to_be_bytes();
+ let seed =
+ IndirectAtom::new_raw_bytes(&mut c.stack, sed_bytes.len(), sed_bytes.as_ptr())
+ .as_noun();
+
+ let sam = T(&mut c.stack, &[message, seed]);
+ let ret = A(&mut c.stack, &ubig!(_0x92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00));
+ assert_jet(c, jet_sign, sam, ret);
+
+ let msg_ubig = ubig!(_0xaf82);
+ let msg_bytes = msg_ubig.to_be_bytes();
+ let message =
+ IndirectAtom::new_raw_bytes(&mut c.stack, msg_bytes.len(), msg_bytes.as_ptr())
+ .as_noun();
+
+ let sed_ubig =
+ ubig!(_0xc5aa8df43f9f837bedb7442f31dcb7b166d38535076f094b85ce3a2e0b4458f7);
+ let sed_bytes = sed_ubig.to_be_bytes();
+ let seed =
+ IndirectAtom::new_raw_bytes(&mut c.stack, sed_bytes.len(), sed_bytes.as_ptr())
+ .as_noun();
+
+ let sam = T(&mut c.stack, &[message, seed]);
+ let ret = A(&mut c.stack, &ubig!(_0x6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a));
+ assert_jet(c, jet_sign, sam, ret);
+ }
+ }
+
+ #[test]
+ fn test_veri() {
+ let c = &mut init_context();
+
+ unsafe {
+ let sig_ubig = ubig!(_0x92a009a9f0d4cab8720e820b5f642540a2b27b5416503f8fb3762223ebdb69da085ac1e43e15996e458f3613d0f11d8c387b2eaeb4302aeeb00d291612bb0c00);
+ let sig_bytes = sig_ubig.to_be_bytes();
+ let signature =
+ IndirectAtom::new_raw_bytes(&mut c.stack, sig_bytes.len(), sig_bytes.as_ptr())
+ .as_noun();
+
+ let message = D(0x72);
+
+ let pub_ubig =
+ ubig!(_0x3d4017c3e843895a92b70aa74d1b7ebc9c982ccf2ec4968cc0cd55f12af4660c);
+ let pub_bytes = pub_ubig.to_be_bytes();
+ let public_key =
+ IndirectAtom::new_raw_bytes(&mut c.stack, pub_bytes.len(), pub_bytes.as_ptr())
+ .as_noun();
+
+ let sam = T(&mut c.stack, &[signature, message, public_key]);
+ assert_jet(c, jet_veri, sam, YES);
+
+ let sig_ubig = ubig!(_0x6291d657deec24024827e69c3abe01a30ce548a284743a445e3680d7db5ac3ac18ff9b538d16f290ae67f760984dc6594a7c15e9716ed28dc027beceea1ec40a);
+ let sig_bytes = sig_ubig.to_be_bytes();
+ let signature =
+ IndirectAtom::new_raw_bytes(&mut c.stack, sig_bytes.len(), sig_bytes.as_ptr())
+ .as_noun();
+
+ let msg_ubig = ubig!(0xaf82);
+ let msg_bytes = msg_ubig.to_be_bytes();
+ let message =
+ IndirectAtom::new_raw_bytes(&mut c.stack, msg_bytes.len(), msg_bytes.as_ptr())
+ .as_noun();
+
+ let pub_ubig =
+ ubig!(_0xfc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025);
+ let pub_bytes = pub_ubig.to_be_bytes();
+ let public_key =
+ IndirectAtom::new_raw_bytes(&mut c.stack, pub_bytes.len(), pub_bytes.as_ptr())
+ .as_noun();
+
+ let sam = T(&mut c.stack, &[signature, message, public_key]);
+ assert_jet(c, jet_veri, sam, YES);
+ }
+ }
+}
diff --git a/rust/ares/src/jets/lock/sha.rs b/rust/ares/src/jets/lock/sha.rs
new file mode 100644
index 0000000..a2d87f3
--- /dev/null
+++ b/rust/ares/src/jets/lock/sha.rs
@@ -0,0 +1,350 @@
+use crate::interpreter::{Context, Error};
+use crate::jets::bits::util::met;
+use crate::jets::util::slot;
+use crate::jets::{JetErr, Result};
+use crate::noun::{IndirectAtom, Noun, D};
+use urcrypt_sys::*;
+
+crate::gdb!();
+
+pub fn jet_shas(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let sal = slot(sam, 2)?.as_atom()?;
+ let ruz = slot(sam, 3)?.as_atom()?;
+
+ let sal_bytes = &(sal.as_bytes())[0..met(3, sal)]; // drop trailing zeros
+ let (mut _salt_ida, salt) = unsafe { IndirectAtom::new_raw_mut_bytes(stack, sal_bytes.len()) };
+ salt.copy_from_slice(sal_bytes);
+
+ let message = &(ruz.as_bytes())[0..met(3, ruz)]; // drop trailing zeros
+
+ unsafe {
+ let (mut out_ida, out) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ urcrypt_shas(
+ salt.as_mut_ptr(),
+ salt.len(),
+ message.as_ptr(),
+ message.len(),
+ out.as_mut_ptr(),
+ );
+ Ok(out_ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_shax(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let msg = sam.as_atom()?;
+ let len = met(3, msg);
+
+ unsafe {
+ let (mut ida, out) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ urcrypt_shay(msg.as_bytes().as_ptr(), len, out.as_mut_ptr());
+ Ok(ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_shay(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let wid = slot(sam, 2)?.as_atom()?;
+ let dat = slot(sam, 3)?.as_atom()?;
+
+ let width = match wid.as_direct() {
+ Ok(direct) => direct.data() as usize,
+ Err(_) => return Err(JetErr::Fail(Error::NonDeterministic(D(0)))),
+ };
+
+ let message = dat.as_bytes();
+
+ unsafe {
+ let (mut out_ida, out) = IndirectAtom::new_raw_mut_bytes(stack, 32);
+ urcrypt_shay(message.as_ptr(), width, out.as_mut_ptr());
+ Ok(out_ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_shal(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let wid = slot(sam, 2)?.as_atom()?;
+ let dat = slot(sam, 3)?.as_atom()?;
+
+ let width = match wid.as_direct() {
+ Ok(direct) => direct.data() as usize,
+ Err(_) => return Err(JetErr::Fail(Error::NonDeterministic(D(0)))),
+ };
+
+ let message = &(dat.as_bytes())[0..met(3, dat)]; // drop trailing zeros
+
+ unsafe {
+ let (mut ida, out) = IndirectAtom::new_raw_mut_bytes(stack, 64);
+ urcrypt_shal(message.as_ptr(), width, out.as_mut_ptr());
+ Ok(ida.normalize_as_atom().as_noun())
+ }
+}
+
+pub fn jet_sha1(context: &mut Context, subject: Noun) -> Result {
+ let stack = &mut context.stack;
+ let sam = slot(subject, 6)?;
+ let wid = slot(sam, 2)?.as_atom()?;
+ let dat = slot(sam, 3)?.as_atom()?;
+
+ let width = match wid.as_direct() {
+ Ok(direct) => direct.data() as usize,
+ Err(_) => return Err(JetErr::Fail(Error::NonDeterministic(D(0)))),
+ };
+
+ unsafe {
+ let msg_bytes = dat.as_bytes();
+ let (mut _msg_ida, msg) = IndirectAtom::new_raw_mut_bytes(stack, msg_bytes.len());
+ msg.copy_from_slice(msg_bytes);
+
+ let (mut out_ida, out) = IndirectAtom::new_raw_mut_bytes(stack, 20);
+ urcrypt_sha1(msg.as_mut_ptr(), width, out.as_mut_ptr());
+ Ok(out_ida.normalize_as_atom().as_noun())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::jets::util::test::{assert_jet, assert_jet_err, assert_jet_ubig, init_context, A};
+ use crate::jets::JetErr;
+ use crate::noun::{D, DIRECT_MAX, T};
+ use ibig::ubig;
+
+ #[test]
+ fn test_shas() {
+ let c = &mut init_context();
+
+ let sam = T(&mut c.stack, &[D(1), D(1)]);
+ assert_jet_ubig(
+ c,
+ jet_shas,
+ sam,
+ ubig!(_0x547da92584bc986e5784edb746c29504bfd6b34572c83b7b96440ca77d35cdfc),
+ );
+
+ let sam = T(&mut c.stack, &[D(2), D(2)]);
+ assert_jet_ubig(
+ c,
+ jet_shas,
+ sam,
+ ubig!(_0x4cf01fe7cc56ef70d17735322488de0d31857afcfe451e199abe6295f78f5328),
+ );
+
+ let a = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ let b = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de73),
+ );
+ let sam = T(&mut c.stack, &[a, b]);
+ assert_jet_ubig(
+ c,
+ jet_shas,
+ sam,
+ ubig!(_0xf7569a89650553ef13f9a8f0bb751fd42b70a4821be6bc1cbe197af33ce4843c),
+ );
+ }
+
+ #[test]
+ fn test_shax() {
+ let c = &mut init_context();
+
+ assert_jet_ubig(
+ c,
+ jet_shax,
+ D(7303014), // 'foo'
+ ubig!(_0xaee76662885e8af9a0bf8364702d42133441301d3c459bf98fc6ff686bb4262c),
+ );
+
+ let a = A(
+ &mut c.stack,
+ &ubig!(_0xaee76662885e8af9a0bf8364702d42133441301d3c459bf98fc6ff686bb4262c),
+ );
+ assert_jet_ubig(
+ c,
+ jet_shax,
+ a,
+ ubig!(_0x9ee26e46c2028aa4a9c463aa722b82ed8bf6e185c3e5a5a69814a2c78fe8adc7),
+ );
+
+ assert_jet_ubig(
+ c,
+ jet_shax,
+ D(123456789),
+ ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+
+ let a = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ assert_jet_ubig(
+ c,
+ jet_shax,
+ a,
+ ubig!(_0xf90f3184d7347a20cfdd2d5f7ac5c82eb9ab7af54c9419fbc18832c5a33360c9),
+ )
+ }
+
+ #[test]
+ fn test_shay() {
+ let c = &mut init_context();
+
+ let sam = T(&mut c.stack, &[D(1), D(0)]);
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0x1da0af1706a31185763837b33f1d90782c0a78bbe644a59c987ab3ff9c0b346e),
+ );
+ assert_jet(c, jet_shay, sam, ret);
+
+ let sam = T(&mut c.stack, &[D(0), D(1)]);
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0x55b852781b9995a44c939b64e441ae2724b96f99c8f4fb9a141cfc9842c4b0e3),
+ );
+ assert_jet(c, jet_shay, sam, ret);
+
+ let sam = T(&mut c.stack, &[D(1), D(478560413032)]); // [1 'hello']
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0x23b14de6713b28aadf8f95026636eb6ab63e99c952bceb401fa4f1642640a9aa),
+ );
+ assert_jet(c, jet_shay, sam, ret);
+
+ let sam = T(&mut c.stack, &[D(2), D(478560413032)]); // [2 'hello']
+ let ret = A(
+ &mut c.stack,
+ &ubig!(_0xde1e7ee30cecf453f1d77c08a125fdc6a4bbac72c01dd7a1e21cd0d22f7e2f37),
+ );
+ assert_jet(c, jet_shay, sam, ret);
+
+ let big = DIRECT_MAX + 1;
+ let ida = unsafe {
+ IndirectAtom::new_raw_bytes(&mut c.stack, 8, &big as *const u64 as *const u8)
+ };
+ let sam = T(&mut c.stack, &[ida.as_noun(), D(478560413032)]);
+ assert_jet_err(
+ c,
+ jet_shay,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+
+ let big: u128 = (DIRECT_MAX as u128) << 64;
+ let ida = unsafe {
+ IndirectAtom::new_raw_bytes(&mut c.stack, 8, &big as *const u128 as *const u8)
+ };
+ let sam = T(&mut c.stack, &[ida.as_noun(), D(478560413032)]);
+ assert_jet_err(
+ c,
+ jet_shay,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+ }
+
+ #[test]
+ fn test_shal() {
+ let c = &mut init_context();
+
+ let sam = T(&mut c.stack, &[D(1), D(1)]);
+ assert_jet_ubig(
+ c,
+ jet_shal,
+ sam,
+ ubig!(_0x39e3d936c6e31eaac08fcfcfe7bb443460c61c0bd5b74408c8bcc35a6b8d6f5700bdcddeaa4b466ae65f8fb67f67ca62dc34149e1d44d213ddfbc13668b6547b)
+ );
+
+ let sam = T(&mut c.stack, &[D(1), D(2)]);
+ assert_jet_ubig(
+ c,
+ jet_shal,
+ sam,
+ ubig!(_0xcadc698fca01cf2935f760278554b4e61f35453975a5bb45389003159bc8485b7018dd8152d9cc23b6e9dd91b107380b9d14ddbf9cc037ee53a857b6c948b8fa)
+ );
+
+ let wid = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ let dat = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de73),
+ );
+ let sam = T(&mut c.stack, &[wid, dat]);
+ assert_jet_err(
+ c,
+ jet_shal,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+
+ let wid = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ let sam = T(&mut c.stack, &[wid, D(1)]);
+ assert_jet_err(
+ c,
+ jet_shal,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+ }
+
+ #[test]
+ fn test_sha1() {
+ let c = &mut init_context();
+
+ let sam = T(&mut c.stack, &[D(1), D(1)]);
+ assert_jet_ubig(
+ c,
+ jet_sha1,
+ sam,
+ ubig!(_0xbf8b4530d8d246dd74ac53a13471bba17941dff7),
+ );
+
+ let sam = T(&mut c.stack, &[D(1), D(2)]);
+ assert_jet_ubig(
+ c,
+ jet_sha1,
+ sam,
+ ubig!(_0xc4ea21bb365bbeeaf5f2c654883e56d11e43c44e),
+ );
+
+ let wid = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ let dat = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de73),
+ );
+ let sam = T(&mut c.stack, &[wid, dat]);
+ assert_jet_err(
+ c,
+ jet_sha1,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+
+ let wid = A(
+ &mut c.stack,
+ &ubig!(_0xa1d6eb6ef33f233ae6980ca7c4fc65f90fe1bdee11c730d41607b4747c83de72),
+ );
+ let sam = T(&mut c.stack, &[wid, D(1)]);
+ assert_jet_err(
+ c,
+ jet_sha1,
+ sam,
+ JetErr::Fail(Error::NonDeterministic(D(0))),
+ );
+ }
+}
diff --git a/rust/nix/libaes_siv.nix b/rust/nix/libaes_siv.nix
new file mode 100644
index 0000000..4e6382f
--- /dev/null
+++ b/rust/nix/libaes_siv.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchFromGitHub, cmake, asciidoc, openssl, libxml2, libxslt, docbook_xml_dtd_45, docbook_xsl}:
+stdenv.mkDerivation {
+ pname = "libaes_siv";
+ version = "1.latest";
+
+ src = fetchFromGitHub {
+ owner = "dfoxfranke";
+ repo = "libaes_siv";
+ rev = "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b";
+ hash = "sha256:1g4wy0m5wpqx7z6nillppkh5zki9fkx9rdw149qcxh7mc5vlszzi";
+ };
+
+ buildInputs = [cmake openssl];
+
+ cmakeFlags = [ "DDISABLE_DOCS" ];
+
+}
diff --git a/rust/nix/overlay.nix b/rust/nix/overlay.nix
new file mode 100644
index 0000000..ea5040a
--- /dev/null
+++ b/rust/nix/overlay.nix
@@ -0,0 +1,4 @@
+self: super: {
+ libaes_siv = self.callPackage ./libaes_siv.nix {};
+ urcrypt = self.callPackage ./urcrypt.nix {};
+}
diff --git a/rust/nix/urcrypt.nix b/rust/nix/urcrypt.nix
new file mode 100644
index 0000000..48f9df8
--- /dev/null
+++ b/rust/nix/urcrypt.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkg-config, openssl, cryptopp, secp256k1, libaes_siv }:
+let rev = "375fa7e6a730d8aa517ca981b2b7b505bf4e1103";
+in stdenv.mkDerivation {
+ pname = "urcrypt";
+ version = "git-${rev}";
+ src = fetchFromGitHub {
+ inherit rev;
+ owner = "urbit";
+ repo = "urcrypt";
+ hash = "sha256:1c3cqmwr5mys4v9y0834hxqfr6aynm2gav7730bjzfvrdc21ijqa";
+ };
+
+ preConfigure = ''
+ ./autogen.sh
+ '';
+
+ nativeBuildInputs = [autoreconfHook pkg-config];
+
+ buildInputs = [openssl cryptopp secp256k1 libaes_siv];
+}
diff --git a/rust/shell.nix b/rust/shell.nix
index d273c0c..167e789 100644
--- a/rust/shell.nix
+++ b/rust/shell.nix
@@ -1,9 +1,10 @@
{ sources ? import ./nix/sources.nix,
pkgs ? import sources.nixpkgs {
- overlays = [ (import "${sources.fenix}/overlay.nix") ];
+ overlays = [ (import "${sources.fenix}/overlay.nix") (import ./nix/overlay.nix) ];
}
}:
pkgs.mkShell {
+ LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
packages = with pkgs; [
(fenix.stable.withComponents [
"cargo"
@@ -14,5 +15,9 @@ pkgs.mkShell {
])
cargo-watch
gdb
+ urcrypt
+ pkg-config
+ autoconf-archive
+ llvmPackages.clang
];
}