beaconcrypt 0.3.11__tar.gz → 0.3.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.github/workflows/go.yml +2 -2
  2. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.github/workflows/release.yml +5 -4
  3. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.github/workflows/rust.yml +4 -0
  4. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/Cargo.lock +38 -27
  5. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/Cargo.toml +24 -4
  6. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/PKG-INFO +1 -1
  7. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/README.md +10 -7
  8. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/beaconcrypt.go +54 -54
  9. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/beaconcrypt.pyi +2 -1
  10. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/bindings.h +2 -75
  11. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/doc/protocol.md +16 -11
  12. beaconcrypt-0.3.12/examples/go/.gitignore +1 -0
  13. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/go/go.mod +1 -1
  14. beaconcrypt-0.3.12/examples/go/go.sum +0 -0
  15. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/python/pyproject.toml +1 -1
  16. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/python/uv.lock +11 -11
  17. beaconcrypt-0.3.12/examples/rust/README.md +6 -0
  18. beaconcrypt-0.3.12/examples/rust/main.rs +109 -0
  19. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/lib.rs +1 -4
  20. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/pqxdh.rs +43 -22
  21. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/pybinds.rs +2 -1
  22. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/schema/cryptoframe.capnp +1 -1
  23. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/shared.rs +116 -34
  24. beaconcrypt-0.3.11/examples/go/go.sum +0 -2
  25. beaconcrypt-0.3.11/src/cnsa2.rs +0 -562
  26. beaconcrypt-0.3.11/src/gobinds.rs +0 -340
  27. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.cargo/config.toml +0 -0
  28. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.github/workflows/codeql.yml +0 -0
  29. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.github/workflows/python.yml +0 -0
  30. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/.gitignore +0 -0
  31. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/LICENSE +0 -0
  32. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/beaconcrypt_test.go +0 -0
  33. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/build.rs +0 -0
  34. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/clippy.toml +0 -0
  35. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/doc/rationale.md +0 -0
  36. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/doc/threat_model.md +0 -0
  37. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/c/CMakeLists.txt +0 -0
  38. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/c/README.md +0 -0
  39. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/c/main.c +0 -0
  40. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/go/README.md +0 -0
  41. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/go/main.go +0 -0
  42. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/python/.gitignore +0 -0
  43. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/python/README.md +0 -0
  44. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/examples/python/main.py +0 -0
  45. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/go.mod +0 -0
  46. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/pyproject.toml +0 -0
  47. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/rustfmt.toml +0 -0
  48. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/scripts/generate_python_stubs.py +0 -0
  49. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/beacon.rs +0 -0
  50. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/cbinds.rs +0 -0
  51. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/error.rs +0 -0
  52. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/schema/phase1.capnp +0 -0
  53. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/schema/phase2.capnp +0 -0
  54. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/schema/protogram.capnp +0 -0
  55. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/src/server.rs +0 -0
  56. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/tests/beacon.rs +0 -0
  57. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/tests/protocol.rs +0 -0
  58. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/tests/server.rs +0 -0
  59. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/tests/test_encryption.py +0 -0
  60. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/tests/test_registration.py +0 -0
  61. {beaconcrypt-0.3.11 → beaconcrypt-0.3.12}/uv.lock +0 -0
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  - name: Build native library
65
65
  if: runner.os != 'Windows'
66
- run: cargo build --verbose --features gobinds
66
+ run: cargo build --verbose --release --features gobinds
67
67
 
68
68
  - name: Build native library on Windows
69
69
  if: runner.os == 'Windows'
@@ -71,7 +71,7 @@ jobs:
71
71
  CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc
72
72
  run: |
73
73
  rustup target add x86_64-pc-windows-gnu
74
- cargo build --verbose --target x86_64-pc-windows-gnu --features gobinds
74
+ cargo build --verbose --release --target x86_64-pc-windows-gnu --features gobinds
75
75
 
76
76
  - name: Test Go module
77
77
  if: runner.os != 'Windows'
@@ -98,19 +98,20 @@ jobs:
98
98
  run: |
99
99
  rustup target add x86_64-pc-windows-gnu --toolchain nightly
100
100
  rustup component add rust-src --toolchain nightly
101
- cargo +nightly rustc --release -Z build-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features beacon,server,pqxdh --crate-type=staticlib
101
+ cargo +nightly rustc --release -Z build-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features gobinds --crate-type=staticlib
102
+ mv target/x86_64-pc-windows-gnu/release/libbeaconcrypt.a target/x86_64-pc-windows-gnu/release/libbeaconcrypt-gobinds-windows-mingw-x86_64.a
103
+ cargo +nightly rustc --release -Z build-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features beacon --crate-type=staticlib
104
+ mv target/x86_64-pc-windows-gnu/release/libbeaconcrypt.a target/x86_64-pc-windows-gnu/release/libbeaconcrypt-beacon-windows-mingw-x86_64.a
102
105
  ls target/x86_64-pc-windows-gnu/release
103
106
  - name: Run tests
104
107
  env:
105
108
  CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc
106
109
  run: cargo test --verbose --target x86_64-pc-windows-gnu
107
- - name: Rename
108
- run: mv target/x86_64-pc-windows-gnu/release/libbeaconcrypt.a target/x86_64-pc-windows-gnu/release/libbeaconcrypt-windows-mingw-x86_64.a
109
110
  - name: Upload release artifact
110
111
  uses: actions/upload-artifact@v7
111
112
  with:
112
113
  name: beaconcrypt-static-windows-mingw-x86_64
113
- path: target/x86_64-pc-windows-gnu/release/libbeaconcrypt-windows-mingw-x86_64.a
114
+ path: target/x86_64-pc-windows-gnu/release/libbeaconcrypt-*.a
114
115
  retention-days: 7
115
116
 
116
117
  release:
@@ -22,5 +22,9 @@ jobs:
22
22
  run: sudo apt update && sudo apt install capnproto
23
23
  - name: Build
24
24
  run: cargo build --verbose
25
+ - name: Check PQXDH server build
26
+ run: cargo check --no-default-features --features pqxdh,server --lib
27
+ - name: Check PQXDH beacon build
28
+ run: cargo check --no-default-features --features pqxdh,beacon --lib
25
29
  - name: Run tests
26
30
  run: cargo test --verbose
@@ -78,7 +78,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
78
78
 
79
79
  [[package]]
80
80
  name = "beaconcrypt"
81
- version = "0.3.11"
81
+ version = "0.3.12"
82
82
  dependencies = [
83
83
  "capnp",
84
84
  "capnpc",
@@ -138,16 +138,16 @@ dependencies = [
138
138
  "quote",
139
139
  "serde",
140
140
  "serde_json",
141
- "syn",
141
+ "syn 2.0.119",
142
142
  "tempfile",
143
143
  "toml",
144
144
  ]
145
145
 
146
146
  [[package]]
147
147
  name = "cc"
148
- version = "1.2.67"
148
+ version = "1.3.0"
149
149
  source = "registry+https://github.com/rust-lang/crates.io-index"
150
- checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38"
150
+ checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8"
151
151
  dependencies = [
152
152
  "find-msvc-tools",
153
153
  "shlex",
@@ -161,9 +161,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
161
161
 
162
162
  [[package]]
163
163
  name = "clap"
164
- version = "4.6.2"
164
+ version = "4.6.3"
165
165
  source = "registry+https://github.com/rust-lang/crates.io-index"
166
- checksum = "dd059f9da4f5c36b3787f65d38ccaab1cc315f07b01f89abc8359ee6a8205011"
166
+ checksum = "0fb99565819980999fb7b4a1796046a5c949e6d4ff132cf5fadf5a641e20d776"
167
167
  dependencies = [
168
168
  "clap_builder",
169
169
  ]
@@ -269,9 +269,9 @@ dependencies = [
269
269
 
270
270
  [[package]]
271
271
  name = "fastrand"
272
- version = "2.4.1"
272
+ version = "2.5.0"
273
273
  source = "registry+https://github.com/rust-lang/crates.io-index"
274
- checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
274
+ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
275
275
 
276
276
  [[package]]
277
277
  name = "filetime"
@@ -379,9 +379,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
379
379
 
380
380
  [[package]]
381
381
  name = "libc"
382
- version = "0.2.186"
382
+ version = "0.2.188"
383
383
  source = "registry+https://github.com/rust-lang/crates.io-index"
384
- checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
384
+ checksum = "22053b6a34f84abc97f9129e61334f40174659a1b9bd18c970b83db6a9a6348b"
385
385
 
386
386
  [[package]]
387
387
  name = "libflate"
@@ -520,9 +520,9 @@ checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
520
520
 
521
521
  [[package]]
522
522
  name = "proc-macro2"
523
- version = "1.0.106"
523
+ version = "1.0.107"
524
524
  source = "registry+https://github.com/rust-lang/crates.io-index"
525
- checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
525
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
526
526
  dependencies = [
527
527
  "unicode-ident",
528
528
  ]
@@ -569,7 +569,7 @@ dependencies = [
569
569
  "proc-macro2",
570
570
  "pyo3-macros-backend",
571
571
  "quote",
572
- "syn",
572
+ "syn 2.0.119",
573
573
  ]
574
574
 
575
575
  [[package]]
@@ -581,14 +581,14 @@ dependencies = [
581
581
  "heck",
582
582
  "proc-macro2",
583
583
  "quote",
584
- "syn",
584
+ "syn 2.0.119",
585
585
  ]
586
586
 
587
587
  [[package]]
588
588
  name = "quote"
589
- version = "1.0.46"
589
+ version = "1.0.47"
590
590
  source = "registry+https://github.com/rust-lang/crates.io-index"
591
- checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
591
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
592
592
  dependencies = [
593
593
  "proc-macro2",
594
594
  ]
@@ -620,9 +620,9 @@ dependencies = [
620
620
 
621
621
  [[package]]
622
622
  name = "serde"
623
- version = "1.0.228"
623
+ version = "1.0.229"
624
624
  source = "registry+https://github.com/rust-lang/crates.io-index"
625
- checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
625
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
626
626
  dependencies = [
627
627
  "serde_core",
628
628
  "serde_derive",
@@ -630,29 +630,29 @@ dependencies = [
630
630
 
631
631
  [[package]]
632
632
  name = "serde_core"
633
- version = "1.0.228"
633
+ version = "1.0.229"
634
634
  source = "registry+https://github.com/rust-lang/crates.io-index"
635
- checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
635
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
636
636
  dependencies = [
637
637
  "serde_derive",
638
638
  ]
639
639
 
640
640
  [[package]]
641
641
  name = "serde_derive"
642
- version = "1.0.228"
642
+ version = "1.0.229"
643
643
  source = "registry+https://github.com/rust-lang/crates.io-index"
644
- checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
644
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
645
645
  dependencies = [
646
646
  "proc-macro2",
647
647
  "quote",
648
- "syn",
648
+ "syn 3.0.2",
649
649
  ]
650
650
 
651
651
  [[package]]
652
652
  name = "serde_json"
653
- version = "1.0.150"
653
+ version = "1.0.151"
654
654
  source = "registry+https://github.com/rust-lang/crates.io-index"
655
- checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
655
+ checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
656
656
  dependencies = [
657
657
  "itoa",
658
658
  "memchr",
@@ -699,6 +699,17 @@ dependencies = [
699
699
  "unicode-ident",
700
700
  ]
701
701
 
702
+ [[package]]
703
+ name = "syn"
704
+ version = "3.0.2"
705
+ source = "registry+https://github.com/rust-lang/crates.io-index"
706
+ checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3"
707
+ dependencies = [
708
+ "proc-macro2",
709
+ "quote",
710
+ "unicode-ident",
711
+ ]
712
+
702
713
  [[package]]
703
714
  name = "tar"
704
715
  version = "0.4.46"
@@ -746,7 +757,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
746
757
  dependencies = [
747
758
  "proc-macro2",
748
759
  "quote",
749
- "syn",
760
+ "syn 2.0.119",
750
761
  ]
751
762
 
752
763
  [[package]]
@@ -897,7 +908,7 @@ checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328"
897
908
  dependencies = [
898
909
  "proc-macro2",
899
910
  "quote",
900
- "syn",
911
+ "syn 2.0.119",
901
912
  ]
902
913
 
903
914
  [[package]]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "beaconcrypt"
3
- version = "0.3.11"
3
+ version = "0.3.12"
4
4
  edition = "2024"
5
5
  license-file = "LICENSE"
6
6
  readme = "README.md"
@@ -12,6 +12,26 @@ repository = "https://github.com/0xd6cb6d73/beaconcrypt"
12
12
  name = "beaconcrypt"
13
13
  crate-type = ["cdylib", "staticlib", "rlib"]
14
14
 
15
+ [[example]]
16
+ name = "rust"
17
+ path = "examples/rust/main.rs"
18
+ required-features = ["pqxdh", "beacon", "server"]
19
+
20
+ [[test]]
21
+ name = "beacon"
22
+ path = "tests/beacon.rs"
23
+ required-features = ["pqxdh", "beacon", "server"]
24
+
25
+ [[test]]
26
+ name = "protocol"
27
+ path = "tests/protocol.rs"
28
+ required-features = ["pqxdh", "beacon", "server"]
29
+
30
+ [[test]]
31
+ name = "server"
32
+ path = "tests/server.rs"
33
+ required-features = ["pqxdh", "beacon", "server"]
34
+
15
35
  [build-dependencies]
16
36
  capnpc = "0.26"
17
37
  cbindgen = "0.29"
@@ -24,10 +44,10 @@ pyo3 = { version = "0.29.0", features = ["abi3-py311", "experimental-inspect"],
24
44
 
25
45
  [features]
26
46
  default = ["beacon", "server", "pqxdh"]
27
- server = []
28
- beacon = []
47
+ server = ["pqxdh"]
48
+ beacon = ["pqxdh"]
29
49
  pqxdh = []
30
- gobinds = ["beacon", "server", "pqxdh"]
50
+ gobinds = ["cbinds"]
31
51
  cbinds = ["beacon", "server", "pqxdh"]
32
52
  pybinds = ["dep:pyo3", "beacon", "server", "pqxdh"]
33
53
  all = ["gobinds", "pybinds", "cbinds"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beaconcrypt
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -58,7 +58,7 @@ For windows, I prefer building with stable-gnu for normal usage, and nightly-gnu
58
58
  Build and run all tests:
59
59
  ```bash
60
60
  cargo test
61
- cargo build --features gobinds --target x86_64-pc-windows-gnu
61
+ cargo build --features gobinds --release --target x86_64-pc-windows-gnu
62
62
  go test -a -count=1 .
63
63
  uv run maturin develop --uv
64
64
  uv run pytest tests
@@ -66,15 +66,18 @@ uv run pytest tests
66
66
 
67
67
  The `-a` flag is required after rebuilding the Rust static library because Go's build cache does not detect changes to libraries linked through cgo. `-count=1` also prevents reuse of a cached successful test result.
68
68
 
69
- ## Profiles
70
- The reference implementation has two profiles: `PQXDH` and `CNSA2`. Profiles are controlled by cargo features. The CNSA2 profile only exists as a test for now. It uses a simple ML-KEM encapsulation for key exchange and the underlying libraries are not FIPS-approved. It is experimental and is likely broken. PQXDH is the intended target and the default.
69
+ ## Usage
70
+ The reference implementation is a library that can currently be used either from rust, through C FFI, go and python bindings. The C interface is currently not tested.
71
71
 
72
- **CNSA2 is currently completely broken**
72
+ From Rust, usage is mostly just instantiating `CryptoProvider` objects. See the [example](examples/rust/main.rs) for usage.
73
73
 
74
- ## Usage
75
- The reference implementation is a library that can currently be used either from rust or through C FFI. The C interface is currently not tested.
74
+ From python, you can just use the wheels published to pypi, see the [example](examples/python/main.py) for usage.
75
+
76
+ There are two C interfaces at the moment. When using the legacy interface (without the `beaconcrypt` prefix) the library creates a global `CryptoProvider` object, whose methods are wrapped by the various functions in the interface. When using this interace, the caller is responsible for the buffers passed into the library. Assume the library does not do any copies, except for initialization functions, and never frees the buffers it is passed.
77
+
78
+ Using the [newer](src/cbinds.rs) C interface which emulate the class interface, the caller is responsible for providing a valid state object to every function. See the [example](examples/c/main.c) for usage.
76
79
 
77
- From rust, usage is mostly just instanciating `CryptoProvider` objects. When using the C FFI, the library creates a global `CryptoProvider` object, whose methods are wrapped by the various functions in the interface. When using the C FFI, the caller is responsible for the buffers passed into the library. Assume the library does not do any copies, except for initialization functions, and never frees the buffers it is passed.
80
+ Go is unfortunately the worst off as the bindings use cgo and therefore building your binary requires being able to link to a version of the library built with the `gobinds` feature. See the [example](examples/go/main.go) for usage.
78
81
 
79
82
  # Copyright
80
83
  This work is dedicated to the public domain.
@@ -3,9 +3,9 @@
3
3
  package beaconcrypt
4
4
 
5
5
  /*
6
- #cgo windows LDFLAGS: -L${SRCDIR}/target/x86_64-pc-windows-gnu/debug -l:libbeaconcrypt.a -lbcrypt -lws2_32 -luserenv -ldbghelp -lntdll
7
- #cgo linux LDFLAGS: -L${SRCDIR}/target/debug -l:libbeaconcrypt.a
8
- #cgo darwin LDFLAGS: ${SRCDIR}/target/debug/libbeaconcrypt.a
6
+ #cgo windows LDFLAGS: -L${SRCDIR}/target/x86_64-pc-windows-gnu/release -l:libbeaconcrypt.a -lbcrypt -lws2_32 -luserenv -ldbghelp -lntdll
7
+ #cgo linux LDFLAGS: -L${SRCDIR}/target/release -l:libbeaconcrypt.a
8
+ #cgo darwin LDFLAGS: ${SRCDIR}/target/release/libbeaconcrypt.a
9
9
  #include <stdint.h>
10
10
  #include <stdlib.h>
11
11
 
@@ -13,31 +13,31 @@ typedef struct {
13
13
  uint8_t *ptr;
14
14
  uintptr_t len;
15
15
  uintptr_t cap;
16
- } beaconcrypt_go_buffer;
16
+ } beaconcrypt_buffer;
17
17
 
18
18
  typedef struct {
19
- beaconcrypt_go_buffer response;
20
- beaconcrypt_go_buffer beacon_pk;
19
+ beaconcrypt_buffer response;
20
+ beaconcrypt_buffer beacon_pk;
21
21
  uint64_t key_id;
22
- } beaconcrypt_go_registration_response;
22
+ } beaconcrypt_registration_response;
23
23
 
24
- void beaconcrypt_go_free_buffer(beaconcrypt_go_buffer buffer);
25
- void *beaconcrypt_go_server_new(uint64_t server_kid);
26
- void *beaconcrypt_go_server_new_from_seed(uint64_t server_kid, const uint8_t *seed_ptr, uintptr_t seed_len);
27
- void *beaconcrypt_go_beacon_new(uint64_t server_kid, const uint8_t *server_pk_ptr, uintptr_t server_pk_len);
28
- void beaconcrypt_go_free(void *handle);
29
- beaconcrypt_go_buffer beaconcrypt_go_identity_pk(const void *handle);
30
- beaconcrypt_go_buffer beaconcrypt_go_generate_registration(void *handle);
31
- beaconcrypt_go_registration_response beaconcrypt_go_register_beacon(void *handle, const uint8_t *reg_ptr, uintptr_t reg_len, const uint8_t *msg_ptr, uintptr_t msg_len);
32
- beaconcrypt_go_buffer beaconcrypt_go_process_initial_message(void *handle, const uint8_t *ptr, uintptr_t len);
33
- beaconcrypt_go_buffer beaconcrypt_go_encrypt_to_beacon(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
34
- beaconcrypt_go_buffer beaconcrypt_go_encrypt_to_beacon_signed(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
35
- beaconcrypt_go_buffer beaconcrypt_go_decrypt_beacon_message(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
36
- beaconcrypt_go_buffer beaconcrypt_go_decrypt_beacon_message_signed(void *handle, const uint8_t *ptr, uintptr_t len);
37
- beaconcrypt_go_buffer beaconcrypt_go_encrypt_to_server(void *handle, const uint8_t *ptr, uintptr_t len);
38
- beaconcrypt_go_buffer beaconcrypt_go_encrypt_to_server_signed(void *handle, const uint8_t *ptr, uintptr_t len);
39
- beaconcrypt_go_buffer beaconcrypt_go_decrypt_server_message(void *handle, const uint8_t *ptr, uintptr_t len);
40
- beaconcrypt_go_buffer beaconcrypt_go_decrypt_server_message_signed(void *handle, const uint8_t *ptr, uintptr_t len);
24
+ void beaconcrypt_free_buffer(beaconcrypt_buffer buffer);
25
+ void *beaconcrypt_server_new(uint64_t server_kid);
26
+ void *beaconcrypt_server_new_from_seed(uint64_t server_kid, const uint8_t *seed_ptr, uintptr_t seed_len);
27
+ void *beaconcrypt_beacon_new(uint64_t server_kid, const uint8_t *server_pk_ptr, uintptr_t server_pk_len);
28
+ void beaconcrypt_free(void *handle);
29
+ beaconcrypt_buffer beaconcrypt_identity_pk(const void *handle);
30
+ beaconcrypt_buffer beaconcrypt_generate_registration(void *handle);
31
+ beaconcrypt_registration_response beaconcrypt_register_beacon(void *handle, const uint8_t *reg_ptr, uintptr_t reg_len, const uint8_t *msg_ptr, uintptr_t msg_len);
32
+ beaconcrypt_buffer beaconcrypt_process_initial_message(void *handle, const uint8_t *ptr, uintptr_t len);
33
+ beaconcrypt_buffer beaconcrypt_encrypt_to_beacon(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
34
+ beaconcrypt_buffer beaconcrypt_encrypt_to_beacon_signed(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
35
+ beaconcrypt_buffer beaconcrypt_decrypt_beacon_message(void *handle, uint64_t key_id, const uint8_t *ptr, uintptr_t len);
36
+ beaconcrypt_buffer beaconcrypt_decrypt_beacon_message_signed(void *handle, const uint8_t *ptr, uintptr_t len);
37
+ beaconcrypt_buffer beaconcrypt_encrypt_to_server(void *handle, const uint8_t *ptr, uintptr_t len);
38
+ beaconcrypt_buffer beaconcrypt_encrypt_to_server_signed(void *handle, const uint8_t *ptr, uintptr_t len);
39
+ beaconcrypt_buffer beaconcrypt_decrypt_server_message(void *handle, const uint8_t *ptr, uintptr_t len);
40
+ beaconcrypt_buffer beaconcrypt_decrypt_server_message_signed(void *handle, const uint8_t *ptr, uintptr_t len);
41
41
  */
42
42
  import "C"
43
43
 
@@ -69,7 +69,7 @@ type RegistrationResponse struct {
69
69
  }
70
70
 
71
71
  func NewServer(serverKID uint64) (*Server, error) {
72
- handle := C.beaconcrypt_go_server_new(C.uint64_t(serverKID))
72
+ handle := C.beaconcrypt_server_new(C.uint64_t(serverKID))
73
73
  if handle == nil {
74
74
  return nil, ErrCrypto
75
75
  }
@@ -84,7 +84,7 @@ func NewServerFromSeed(serverKID uint64, seed []byte) (*Server, error) {
84
84
  }
85
85
  ptr, free := cBytes(seed)
86
86
  defer free()
87
- handle := C.beaconcrypt_go_server_new_from_seed(C.uint64_t(serverKID), ptr, C.uintptr_t(len(seed)))
87
+ handle := C.beaconcrypt_server_new_from_seed(C.uint64_t(serverKID), ptr, C.uintptr_t(len(seed)))
88
88
  if handle == nil {
89
89
  return nil, ErrCrypto
90
90
  }
@@ -96,7 +96,7 @@ func NewServerFromSeed(serverKID uint64, seed []byte) (*Server, error) {
96
96
  func NewBeacon(serverKID uint64, serverPK []byte) (*Beacon, error) {
97
97
  ptr, free := cBytes(serverPK)
98
98
  defer free()
99
- handle := C.beaconcrypt_go_beacon_new(C.uint64_t(serverKID), ptr, C.uintptr_t(len(serverPK)))
99
+ handle := C.beaconcrypt_beacon_new(C.uint64_t(serverKID), ptr, C.uintptr_t(len(serverPK)))
100
100
  if handle == nil {
101
101
  return nil, ErrCrypto
102
102
  }
@@ -107,7 +107,7 @@ func NewBeacon(serverKID uint64, serverPK []byte) (*Beacon, error) {
107
107
 
108
108
  func (s *Server) Close() {
109
109
  if s != nil && s.handle != nil {
110
- C.beaconcrypt_go_free(s.handle)
110
+ C.beaconcrypt_free(s.handle)
111
111
  s.handle = nil
112
112
  runtime.SetFinalizer(s, nil)
113
113
  }
@@ -115,7 +115,7 @@ func (s *Server) Close() {
115
115
 
116
116
  func (b *Beacon) Close() {
117
117
  if b != nil && b.handle != nil {
118
- C.beaconcrypt_go_free(b.handle)
118
+ C.beaconcrypt_free(b.handle)
119
119
  b.handle = nil
120
120
  runtime.SetFinalizer(b, nil)
121
121
  }
@@ -125,14 +125,14 @@ func (s *Server) IdentityPK() ([]byte, error) {
125
125
  if s == nil || s.handle == nil {
126
126
  return nil, ErrClosed
127
127
  }
128
- return copyBuffer(C.beaconcrypt_go_identity_pk(s.handle))
128
+ return copyBuffer(C.beaconcrypt_identity_pk(s.handle))
129
129
  }
130
130
 
131
131
  func (b *Beacon) GenerateRegistration() ([]byte, error) {
132
132
  if b == nil || b.handle == nil {
133
133
  return nil, ErrClosed
134
134
  }
135
- return copyBuffer(C.beaconcrypt_go_generate_registration(b.handle))
135
+ return copyBuffer(C.beaconcrypt_generate_registration(b.handle))
136
136
  }
137
137
 
138
138
  func (s *Server) RegisterBeacon(registration, initialMessage []byte) (*RegistrationResponse, error) {
@@ -146,7 +146,7 @@ func (s *Server) RegisterBeacon(registration, initialMessage []byte) (*Registrat
146
146
  defer regFree()
147
147
  msgPtr, msgFree := cBytes(initialMessage)
148
148
  defer msgFree()
149
- response := C.beaconcrypt_go_register_beacon(
149
+ response := C.beaconcrypt_register_beacon(
150
150
  s.handle,
151
151
  regPtr,
152
152
  C.uintptr_t(len(registration)),
@@ -155,7 +155,7 @@ func (s *Server) RegisterBeacon(registration, initialMessage []byte) (*Registrat
155
155
  )
156
156
  serialized, err := copyBuffer(response.response)
157
157
  if err != nil {
158
- C.beaconcrypt_go_free_buffer(response.beacon_pk)
158
+ C.beaconcrypt_free_buffer(response.beacon_pk)
159
159
  return nil, err
160
160
  }
161
161
  beaconPK, err := copyBuffer(response.beacon_pk)
@@ -173,8 +173,8 @@ func (b *Beacon) ProcessInitialMessage(data []byte) ([]byte, error) {
173
173
  if b == nil || b.handle == nil {
174
174
  return nil, ErrClosed
175
175
  }
176
- return callUnary(data, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
177
- return C.beaconcrypt_go_process_initial_message(b.handle, ptr, len)
176
+ return callUnary(data, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
177
+ return C.beaconcrypt_process_initial_message(b.handle, ptr, len)
178
178
  })
179
179
  }
180
180
 
@@ -182,8 +182,8 @@ func (s *Server) EncryptToBeacon(keyID uint64, plaintext []byte) ([]byte, error)
182
182
  if s == nil || s.handle == nil {
183
183
  return nil, ErrClosed
184
184
  }
185
- return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
186
- return C.beaconcrypt_go_encrypt_to_beacon(s.handle, C.uint64_t(keyID), ptr, len)
185
+ return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
186
+ return C.beaconcrypt_encrypt_to_beacon(s.handle, C.uint64_t(keyID), ptr, len)
187
187
  })
188
188
  }
189
189
 
@@ -191,8 +191,8 @@ func (s *Server) EncryptToBeaconSigned(keyID uint64, plaintext []byte) ([]byte,
191
191
  if s == nil || s.handle == nil {
192
192
  return nil, ErrClosed
193
193
  }
194
- return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
195
- return C.beaconcrypt_go_encrypt_to_beacon_signed(s.handle, C.uint64_t(keyID), ptr, len)
194
+ return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
195
+ return C.beaconcrypt_encrypt_to_beacon_signed(s.handle, C.uint64_t(keyID), ptr, len)
196
196
  })
197
197
  }
198
198
 
@@ -200,8 +200,8 @@ func (s *Server) DecryptBeaconMessage(keyID uint64, ciphertext []byte) ([]byte,
200
200
  if s == nil || s.handle == nil {
201
201
  return nil, ErrClosed
202
202
  }
203
- return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
204
- return C.beaconcrypt_go_decrypt_beacon_message(s.handle, C.uint64_t(keyID), ptr, len)
203
+ return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
204
+ return C.beaconcrypt_decrypt_beacon_message(s.handle, C.uint64_t(keyID), ptr, len)
205
205
  })
206
206
  }
207
207
 
@@ -209,8 +209,8 @@ func (s *Server) DecryptBeaconMessageSigned(ciphertext []byte) ([]byte, error) {
209
209
  if s == nil || s.handle == nil {
210
210
  return nil, ErrClosed
211
211
  }
212
- return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
213
- return C.beaconcrypt_go_decrypt_beacon_message_signed(s.handle, ptr, len)
212
+ return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
213
+ return C.beaconcrypt_decrypt_beacon_message_signed(s.handle, ptr, len)
214
214
  })
215
215
  }
216
216
 
@@ -218,8 +218,8 @@ func (b *Beacon) EncryptToServer(plaintext []byte) ([]byte, error) {
218
218
  if b == nil || b.handle == nil {
219
219
  return nil, ErrClosed
220
220
  }
221
- return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
222
- return C.beaconcrypt_go_encrypt_to_server(b.handle, ptr, len)
221
+ return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
222
+ return C.beaconcrypt_encrypt_to_server(b.handle, ptr, len)
223
223
  })
224
224
  }
225
225
 
@@ -227,8 +227,8 @@ func (b *Beacon) EncryptToServerSigned(plaintext []byte) ([]byte, error) {
227
227
  if b == nil || b.handle == nil {
228
228
  return nil, ErrClosed
229
229
  }
230
- return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
231
- return C.beaconcrypt_go_encrypt_to_server_signed(b.handle, ptr, len)
230
+ return callUnary(plaintext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
231
+ return C.beaconcrypt_encrypt_to_server_signed(b.handle, ptr, len)
232
232
  })
233
233
  }
234
234
 
@@ -236,8 +236,8 @@ func (b *Beacon) DecryptServerMessage(ciphertext []byte) ([]byte, error) {
236
236
  if b == nil || b.handle == nil {
237
237
  return nil, ErrClosed
238
238
  }
239
- return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
240
- return C.beaconcrypt_go_decrypt_server_message(b.handle, ptr, len)
239
+ return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
240
+ return C.beaconcrypt_decrypt_server_message(b.handle, ptr, len)
241
241
  })
242
242
  }
243
243
 
@@ -245,12 +245,12 @@ func (b *Beacon) DecryptServerMessageSigned(ciphertext []byte) ([]byte, error) {
245
245
  if b == nil || b.handle == nil {
246
246
  return nil, ErrClosed
247
247
  }
248
- return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_go_buffer {
249
- return C.beaconcrypt_go_decrypt_server_message_signed(b.handle, ptr, len)
248
+ return callUnary(ciphertext, func(ptr *C.uint8_t, len C.uintptr_t) C.beaconcrypt_buffer {
249
+ return C.beaconcrypt_decrypt_server_message_signed(b.handle, ptr, len)
250
250
  })
251
251
  }
252
252
 
253
- func callUnary(data []byte, call func(*C.uint8_t, C.uintptr_t) C.beaconcrypt_go_buffer) ([]byte, error) {
253
+ func callUnary(data []byte, call func(*C.uint8_t, C.uintptr_t) C.beaconcrypt_buffer) ([]byte, error) {
254
254
  if len(data) == 0 {
255
255
  return nil, ErrEmptyData
256
256
  }
@@ -259,11 +259,11 @@ func callUnary(data []byte, call func(*C.uint8_t, C.uintptr_t) C.beaconcrypt_go_
259
259
  return copyBuffer(call(ptr, C.uintptr_t(len(data))))
260
260
  }
261
261
 
262
- func copyBuffer(buffer C.beaconcrypt_go_buffer) ([]byte, error) {
262
+ func copyBuffer(buffer C.beaconcrypt_buffer) ([]byte, error) {
263
263
  if buffer.ptr == nil {
264
264
  return nil, ErrCrypto
265
265
  }
266
- defer C.beaconcrypt_go_free_buffer(buffer)
266
+ defer C.beaconcrypt_free_buffer(buffer)
267
267
  if buffer.len == 0 {
268
268
  return []byte{}, nil
269
269
  }
@@ -14,7 +14,8 @@ class BeaconCryptBeacon:
14
14
  """
15
15
  def process_initial_message(self, /, data: Sequence[int]) -> bytes |None:
16
16
  """
17
- Process the registration response and optional initial data. The raw buffer sent by the server must be passed as-is as `data`. The response contains the contents of the initial message, or nothing if there was none. Once this function returns, the beacon is registered
17
+ Process the registration response and optional initial data. The raw buffer sent by the server must be passed as-is as `data`.
18
+ The response contains the contents of the initial message, or `0xFF` if there was none. Once this function returns, the beacon is registered
18
19
  """
19
20
 
20
21
  @final