diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e8d53d8..b99ca19c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.9.0] - Unreleased + +### Added + +- Re-exported `ferveo` Python and WASM bindings. ([#58]) + +### Changed + +- Replaced opaque types with native `ferveo` types. ([#53]) + + +[#53]: https://github.com/nucypher/nucypher-core/pull/53 +[#58]: https://github.com/nucypher/nucypher-core/pull/58 + + ## [0.8.0] - 2023-05-23 ### Added -- Add `EncryptedThresholdDecryptionRequest`/`EncryptedThresholdDecryptionResponse` types and bindings. ([#52])` +- Add `EncryptedThresholdDecryptionRequest`/`EncryptedThresholdDecryptionResponse` types and bindings. ([#52]) ### Changed diff --git a/Cargo.lock b/Cargo.lock index 555c8439..231d33d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aead" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", "generic-array", @@ -100,7 +100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -113,7 +113,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -149,7 +149,7 @@ checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -182,9 +182,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bincode" @@ -203,18 +203,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byteorder" @@ -236,9 +236,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fc89c7c5b9e7a02dfe45cd2367bae382f9ed31c61ca8debe5f827c420a2f08" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", "cipher", @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbc37d37da9e5bce8173f3a41b71d9bf3c674deebbaceacd0ebdabde76efb03" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ "android-tzdata", "iana-time-zone", @@ -273,9 +273,9 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", @@ -306,9 +306,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -367,7 +367,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -392,7 +392,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -424,7 +424,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -435,14 +435,14 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "const-oid", @@ -505,9 +505,9 @@ dependencies = [ [[package]] name = "ferveo-pre-release" -version = "0.1.0-alpha.7" +version = "0.1.0-alpha.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35cb606e512c72abf2d847b4bbe437ce6930c07023e2310337d3c05f80b0203d" +checksum = "3eb36a788400eb4579a83623696b1e4feb9ea7a47df03e771ac5c990f763ef2d" dependencies = [ "ark-bls12-381", "ark-ec", @@ -520,7 +520,7 @@ dependencies = [ "derive_more", "ferveo-common-pre-release", "generic-array", - "getrandom 0.2.8", + "getrandom 0.2.9", "group-threshold-cryptography-pre-release", "hex", "itertools", @@ -579,9 +579,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "js-sys", @@ -773,18 +773,18 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] [[package]] name = "libc" -version = "0.2.139" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "lock_api" @@ -798,12 +798,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "measure_time" @@ -852,7 +849,7 @@ dependencies = [ "ferveo-pre-release", "nucypher-core", "pyo3", - "pyo3-build-config", + "pyo3-build-config 0.19.0", "umbral-pre", ] @@ -903,9 +900,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "opaque-debug" @@ -938,9 +935,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "poly1305" @@ -979,7 +976,7 @@ dependencies = [ "libc", "memoffset", "parking_lot", - "pyo3-build-config", + "pyo3-build-config 0.18.3", "pyo3-ffi", "pyo3-macros", "unindent", @@ -995,6 +992,16 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "pyo3-build-config" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713eccf888fb05f1a96eb78c0dbc51907fee42b3377272dc902eb38985f418d5" +dependencies = [ + "once_cell", + "target-lexicon", +] + [[package]] name = "pyo3-ffi" version = "0.18.3" @@ -1002,7 +1009,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" dependencies = [ "libc", - "pyo3-build-config", + "pyo3-build-config 0.18.3", ] [[package]] @@ -1014,7 +1021,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1025,7 +1032,7 @@ checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1096,7 +1103,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -1178,9 +1185,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sec1" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct", "der", @@ -1270,7 +1277,7 @@ dependencies = [ "darling 0.13.4", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1298,9 +1305,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest", "keccak", @@ -1343,15 +1350,15 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1369,18 +1376,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.107", - "unicode-xid", -] - [[package]] name = "target-lexicon" version = "0.12.7" @@ -1446,11 +1441,11 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "594a478131f30b32cf28a822d95821ef32881e9773d567739c09df9f2accd692" dependencies = [ - "base64 0.21.0", + "base64 0.21.2", "chacha20poly1305", "derive_more", "generic-array", - "getrandom 0.2.8", + "getrandom 0.2.9", "hex", "hkdf", "js-sys", @@ -1468,15 +1463,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "unicode-xid" -version = "0.2.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unindent" @@ -1486,9 +1475,9 @@ checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" [[package]] name = "universal-hash" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", "subtle", @@ -1539,15 +1528,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-derive" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3451353ff163a0d7053a2b0e1e2b698a466317791b027c50142bb0d3387fb90" +checksum = "c1ab6c8bffb3f89584781211283fb57337d6902faab6eaee38f336977bdf177d" dependencies = [ "js-sys", + "wasm-bindgen", + "wasm-bindgen-derive-macro", +] + +[[package]] +name = "wasm-bindgen-derive-macro" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b87c28b31d27616bc69a891700ef0445d2cbaa0340fdacb145145256d5f5fcbb" +dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", - "wasm-bindgen", + "syn 1.0.109", ] [[package]] @@ -1617,9 +1615,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -1790,12 +1788,11 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", - "synstructure", + "syn 2.0.18", ] diff --git a/nucypher-core-python/Cargo.toml b/nucypher-core-python/Cargo.toml index 7ec5ebbd..7372d359 100644 --- a/nucypher-core-python/Cargo.toml +++ b/nucypher-core-python/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] pyo3 = "0.18" nucypher-core = { path = "../nucypher-core" } umbral-pre = { version = "0.10.0", features = ["bindings-python"] } -ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.7", features = ["bindings-python"] } +ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.8", features = ["bindings-python"] } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } [build-dependencies] diff --git a/nucypher-core-python/nucypher_core/__init__.pyi b/nucypher-core-python/nucypher_core/__init__.pyi index 0ec56072..fb2d3332 100644 --- a/nucypher-core-python/nucypher_core/__init__.pyi +++ b/nucypher-core-python/nucypher_core/__init__.pyi @@ -10,6 +10,11 @@ from .umbral import ( RecoverableSignature ) +from .ferveo import ( + FerveoPublicKey, + Ciphertext +) + class Address: @@ -300,7 +305,7 @@ class NodeMetadataPayload: timestamp_epoch: int, verifying_key: PublicKey, encrypting_key: PublicKey, - ferveo_public_key: bytes, + ferveo_public_key: FerveoPublicKey, certificate_der: bytes, host: str, port: int, @@ -314,7 +319,7 @@ class NodeMetadataPayload: encrypting_key: PublicKey - ferveo_public_key: bytes + ferveo_public_key: FerveoPublicKey operator_signature: RecoverableSignature @@ -405,7 +410,7 @@ class MetadataResponse: class ThresholdDecryptionRequest: - def __init__(self, ritual_id: int, variant: int, ciphertext: bytes, conditions: Optional[Conditions], context: Optional[Context]): + def __init__(self, ritual_id: int, variant: int, ciphertext: Ciphertext, conditions: Optional[Conditions], context: Optional[Context]): ... ritual_id: int @@ -416,7 +421,7 @@ class ThresholdDecryptionRequest: variant: int - ciphertext: bytes + ciphertext: Ciphertext def encrypt(self, request_encrypting_key: PublicKey, response_encrypting_key: PublicKey) -> EncryptedThresholdDecryptionRequest: ... diff --git a/nucypher-core-python/nucypher_core/ferveo.py b/nucypher-core-python/nucypher_core/ferveo.py new file mode 100644 index 00000000..266d4b86 --- /dev/null +++ b/nucypher-core-python/nucypher_core/ferveo.py @@ -0,0 +1,37 @@ +from ._nucypher_core import ferveo as _ferveo + +Keypair = _ferveo.Keypair +FerveoPublicKey = _ferveo.FerveoPublicKey + +encrypt = _ferveo.encrypt +combine_decryption_shares_simple = _ferveo.combine_decryption_shares_simple +combine_decryption_shares_precomputed = _ferveo.combine_decryption_shares_precomputed +decrypt_with_shared_secret = _ferveo.decrypt_with_shared_secret + +Validator = _ferveo.Validator +Transcript = _ferveo.Transcript +Dkg = _ferveo.Dkg +Ciphertext = _ferveo.Ciphertext +DecryptionShareSimple = _ferveo.DecryptionShareSimple +DecryptionSharePrecomputed = _ferveo.DecryptionSharePrecomputed +AggregatedTranscript = _ferveo.AggregatedTranscript +DkgPublicKey = _ferveo.DkgPublicKey +DkgPublicParameters = _ferveo.DkgPublicParameters +SharedSecret = _ferveo.SharedSecret +ThresholdEncryptionError = _ferveo.ThresholdEncryptionError +InvalidShareNumberParameter = _ferveo.InvalidShareNumberParameter +InvalidDkgStateToDeal = _ferveo.InvalidDkgStateToDeal +InvalidDkgStateToAggregate = _ferveo.InvalidDkgStateToAggregate +InvalidDkgStateToVerify = _ferveo.InvalidDkgStateToVerify +InvalidDkgStateToIngest = _ferveo.InvalidDkgStateToIngest +DealerNotInValidatorSet = _ferveo.DealerNotInValidatorSet +UnknownDealer = _ferveo.UnknownDealer +DuplicateDealer = _ferveo.DuplicateDealer +InvalidPvssTranscript = _ferveo.InvalidPvssTranscript +InsufficientTranscriptsForAggregate = _ferveo.InsufficientTranscriptsForAggregate +InvalidDkgPublicKey = _ferveo.InvalidDkgPublicKey +InsufficientValidators = _ferveo.InsufficientValidators +InvalidTranscriptAggregate = _ferveo.InvalidTranscriptAggregate +ValidatorsNotSorted = _ferveo.ValidatorsNotSorted +ValidatorPublicKeyMismatch = _ferveo.ValidatorPublicKeyMismatch +SerializationError = _ferveo.SerializationError diff --git a/nucypher-core-python/nucypher_core/ferveo.pyi b/nucypher-core-python/nucypher_core/ferveo.pyi new file mode 100644 index 00000000..d0ab96e2 --- /dev/null +++ b/nucypher-core-python/nucypher_core/ferveo.pyi @@ -0,0 +1,261 @@ +from typing import Sequence, Tuple + + +class Keypair: + @staticmethod + def random() -> Keypair: + ... + + @staticmethod + def from_secure_randomness(data: bytes) -> Keypair: + ... + + @staticmethod + def secure_randomness_size(data: bytes) -> int: + ... + + @staticmethod + def from_bytes(data: bytes) -> Keypair: + ... + + def __bytes__(self) -> bytes: + ... + + def public_key(self) -> FerveoPublicKey: + ... + + +class FerveoPublicKey: + @staticmethod + def from_bytes(data: bytes) -> FerveoPublicKey: + ... + + def __bytes__(self) -> bytes: + ... + + def __hash__(self) -> int: + ... + + +class Validator: + + def __init__(self, address: str, public_key: FerveoPublicKey): + ... + + address: str + + public_key: FerveoPublicKey + + +class Transcript: + @staticmethod + def from_bytes(data: bytes) -> Transcript: + ... + + def __bytes__(self) -> bytes: + ... + + +class DkgPublicKey: + @staticmethod + def from_bytes(data: bytes) -> DkgPublicKey: + ... + + def __bytes__(self) -> bytes: + ... + + +class Dkg: + + def __init__( + self, + tau: int, + shares_num: int, + security_threshold: int, + validators: Sequence[Validator], + me: Validator, + ): + ... + + public_key: DkgPublicKey + + public_params: DkgPublicParameters + + def generate_transcript(self) -> Transcript: + ... + + def aggregate_transcripts(self, messages: Sequence[Tuple[Validator, Transcript]]) -> AggregatedTranscript: + ... + + +class Ciphertext: + @staticmethod + def from_bytes(data: bytes) -> Ciphertext: + ... + + def __bytes__(self) -> bytes: + ... + + +class DecryptionShareSimple: + @staticmethod + def from_bytes(data: bytes) -> DecryptionShareSimple: + ... + + def __bytes__(self) -> bytes: + ... + + +class DecryptionSharePrecomputed: + @staticmethod + def from_bytes(data: bytes) -> DecryptionSharePrecomputed: + ... + + def __bytes__(self) -> bytes: + ... + + +class DkgPublicParameters: + @staticmethod + def from_bytes(data: bytes) -> DkgPublicParameters: + ... + + def __bytes__(self) -> bytes: + ... + + +class AggregatedTranscript: + + def __init__(self, messages: Sequence[Tuple[Validator, Transcript]]): + ... + + def verify(self, shares_num: int, messages: Sequence[Tuple[Validator, Transcript]]) -> bool: + ... + + def create_decryption_share_simple( + self, + dkg: Dkg, + ciphertext: Ciphertext, + aad: bytes, + validator_keypair: Keypair + ) -> DecryptionShareSimple: + ... + + def create_decryption_share_precomputed( + self, + dkg: Dkg, + ciphertext: Ciphertext, + aad: bytes, + validator_keypair: Keypair + ) -> DecryptionSharePrecomputed: + ... + + @staticmethod + def from_bytes(data: bytes) -> AggregatedTranscript: + ... + + def __bytes__(self) -> bytes: + ... + + +class SharedSecret: + + @staticmethod + def from_bytes(data: bytes) -> SharedSecret: + ... + + def __bytes__(self) -> bytes: + ... + + +def encrypt(message: bytes, add: bytes, dkg_public_key: DkgPublicKey) -> Ciphertext: + ... + + +def combine_decryption_shares_simple( + decryption_shares: Sequence[DecryptionShareSimple], +) -> bytes: + ... + + +def combine_decryption_shares_precomputed( + decryption_shares: Sequence[DecryptionSharePrecomputed], +) -> SharedSecret: + ... + + +def decrypt_with_shared_secret( + ciphertext: Ciphertext, + aad: bytes, + shared_secret: SharedSecret, + dkg_params: DkgPublicParameters, +) -> bytes: + ... + + +class ThresholdEncryptionError(Exception): + pass + + +class InvalidShareNumberParameter(Exception): + pass + + +class InvalidDkgStateToDeal(Exception): + pass + + +class InvalidDkgStateToAggregate(Exception): + pass + + +class InvalidDkgStateToVerify(Exception): + pass + + +class InvalidDkgStateToIngest(Exception): + pass + + +class DealerNotInValidatorSet(Exception): + pass + + +class UnknownDealer(Exception): + pass + + +class DuplicateDealer(Exception): + pass + + +class InvalidPvssTranscript(Exception): + pass + + +class InsufficientTranscriptsForAggregate(Exception): + pass + + +class InvalidDkgPublicKey(Exception): + pass + + +class InsufficientValidators(Exception): + pass + + +class InvalidTranscriptAggregate(Exception): + pass + + +class ValidatorsNotSorted(Exception): + pass + + +class ValidatorPublicKeyMismatch(Exception): + pass + + +class SerializationError(Exception): + pass diff --git a/nucypher-core-python/nucypher_core/umbral.py b/nucypher-core-python/nucypher_core/umbral.py index 63c43459..603c8513 100644 --- a/nucypher-core-python/nucypher_core/umbral.py +++ b/nucypher-core-python/nucypher_core/umbral.py @@ -2,7 +2,7 @@ SecretKey = _umbral.SecretKey PublicKey = _umbral.PublicKey -SecretKeyFactory =_umbral.SecretKeyFactory +SecretKeyFactory = _umbral.SecretKeyFactory Signature = _umbral.Signature RecoverableSignature = _umbral.RecoverableSignature Signer = _umbral.Signer diff --git a/nucypher-core-python/setup.py b/nucypher-core-python/setup.py index e67a3902..1beb6bff 100644 --- a/nucypher-core-python/setup.py +++ b/nucypher-core-python/setup.py @@ -17,7 +17,7 @@ rust_extensions=[RustExtension("nucypher_core._nucypher_core", binding=Binding.PyO3, debug=False)], packages=["nucypher_core"], package_data = { - 'nucypher_core': ['py.typed', '__init__.pyi', 'umbral.pyi'], + 'nucypher_core': ['py.typed', '__init__.pyi', 'umbral.pyi', 'ferveo.pyi'], }, # rust extensions are not zip safe, just like C-extensions. zip_safe=False, diff --git a/nucypher-core-python/src/lib.rs b/nucypher-core-python/src/lib.rs index e4b220cb..7aab285d 100644 --- a/nucypher-core-python/src/lib.rs +++ b/nucypher-core-python/src/lib.rs @@ -7,6 +7,7 @@ extern crate alloc; use alloc::collections::{BTreeMap, BTreeSet}; +use ferveo::bindings_python::{Ciphertext, FerveoPublicKey}; use pyo3::class::basic::CompareOp; use pyo3::exceptions::{PyTypeError, PyValueError}; use pyo3::prelude::*; @@ -17,8 +18,6 @@ use umbral_pre::bindings_python::{ VerifiedCapsuleFrag, VerifiedKeyFrag, }; -use ferveo::bindings_python::{Ciphertext, PublicKey as FerveoPublicKey}; - use nucypher_core::FerveoVariant; use nucypher_core::ProtocolObject; @@ -1315,30 +1314,30 @@ impl MetadataResponse { /// A Python module implemented in Rust. #[pymodule] -fn _nucypher_core(py: Python, m: &PyModule) -> PyResult<()> { - m.add_class::
()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; +fn _nucypher_core(py: Python, core_module: &PyModule) -> PyResult<()> { + core_module.add_class::
()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; + core_module.add_class::()?; // Build the umbral module let umbral_module = PyModule::new(py, "umbral")?; @@ -1364,13 +1363,12 @@ fn _nucypher_core(py: Python, m: &PyModule) -> PyResult<()> { "VerificationError", py.get_type::(), )?; // depends on what `reencryption_response.verify()` returns - m.add_submodule(umbral_module)?; + core_module.add_submodule(umbral_module)?; // Build the ferveo module let ferveo_module = PyModule::new(py, "ferveo")?; - - umbral_module.add_class::()?; - m.add_submodule(ferveo_module)?; + ferveo::bindings_python::make_ferveo_py_module(py, ferveo_module)?; + core_module.add_submodule(ferveo_module)?; Ok(()) } diff --git a/nucypher-core-wasm/Cargo.toml b/nucypher-core-wasm/Cargo.toml index 59f8c658..1ebb0814 100644 --- a/nucypher-core-wasm/Cargo.toml +++ b/nucypher-core-wasm/Cargo.toml @@ -20,13 +20,13 @@ default = ["console_error_panic_hook"] [dependencies] umbral-pre = { version = "0.10.0", features = ["bindings-wasm"] } -ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.7", features = ["bindings-wasm"] } +ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.8", features = ["bindings-wasm"] } nucypher-core = { path = "../nucypher-core" } wasm-bindgen = "0.2.86" js-sys = "0.3.63" console_error_panic_hook = { version = "0.1", optional = true } derive_more = { version = "0.99", default-features = false, features = ["from", "as_ref"] } -wasm-bindgen-derive = "0.2.0" +wasm-bindgen-derive = "0.2.1" [dev-dependencies] console_error_panic_hook = "0.1" diff --git a/nucypher-core/Cargo.toml b/nucypher-core/Cargo.toml index 6509fd60..d8298b86 100644 --- a/nucypher-core/Cargo.toml +++ b/nucypher-core/Cargo.toml @@ -11,7 +11,7 @@ categories = ["cryptography", "no-std"] [dependencies] umbral-pre = { version = "0.10.0", features = ["serde"] } -ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.7" } +ferveo = { package = "ferveo-pre-release", version = "0.1.0-alpha.8" } serde = { version = "1", default-features = false, features = ["derive"] } generic-array = "0.14" sha3 = "0.10"