@digitaldefiance/node-ecies-lib 4.5.19 → 4.6.3
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.
- package/package.json +2 -2
- package/src/builders/ecies-builder.d.ts +11 -0
- package/src/builders/ecies-builder.d.ts.map +1 -0
- package/src/builders/ecies-builder.js +26 -0
- package/src/builders/ecies-builder.js.map +1 -0
- package/src/builders/index.d.ts +3 -0
- package/src/builders/index.d.ts.map +1 -0
- package/src/builders/index.js +6 -0
- package/src/builders/index.js.map +1 -0
- package/src/builders/member-builder.d.ts +47 -0
- package/src/builders/member-builder.d.ts.map +1 -0
- package/src/builders/member-builder.js +99 -0
- package/src/builders/member-builder.js.map +1 -0
- package/src/constants.d.ts +38 -0
- package/src/constants.d.ts.map +1 -0
- package/src/constants.js +191 -0
- package/src/constants.js.map +1 -0
- package/src/core/errors/crypto-error.d.ts +6 -0
- package/src/core/errors/crypto-error.d.ts.map +1 -0
- package/src/core/errors/crypto-error.js +15 -0
- package/src/core/errors/crypto-error.js.map +1 -0
- package/src/core/index.d.ts +3 -0
- package/src/core/index.d.ts.map +1 -0
- package/src/core/index.js +6 -0
- package/src/core/index.js.map +1 -0
- package/src/core/types/result.d.ts +8 -0
- package/src/core/types/result.d.ts.map +1 -0
- package/src/core/types/result.js +3 -0
- package/src/core/types/result.js.map +1 -0
- package/src/enumerations/index.d.ts +3 -0
- package/src/enumerations/index.d.ts.map +1 -0
- package/src/enumerations/index.js +6 -0
- package/src/enumerations/index.js.map +1 -0
- package/src/enumerations/pbkdf2-profile.d.ts +9 -0
- package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
- package/src/enumerations/pbkdf2-profile.js +13 -0
- package/src/enumerations/pbkdf2-profile.js.map +1 -0
- package/src/enumerations/voting-error-type.d.ts +37 -0
- package/src/enumerations/voting-error-type.d.ts.map +1 -0
- package/src/enumerations/voting-error-type.js +48 -0
- package/src/enumerations/voting-error-type.js.map +1 -0
- package/src/errors/index.d.ts +2 -0
- package/src/errors/index.d.ts.map +1 -0
- package/src/errors/index.js +5 -0
- package/src/errors/index.js.map +1 -0
- package/src/errors/voting.d.ts +16 -0
- package/src/errors/voting.d.ts.map +1 -0
- package/src/errors/voting.js +27 -0
- package/src/errors/voting.js.map +1 -0
- package/src/i18n/ecies-i18n-factory.d.ts +28 -0
- package/src/i18n/ecies-i18n-factory.d.ts.map +1 -0
- package/src/i18n/ecies-i18n-factory.js +90 -0
- package/src/i18n/ecies-i18n-factory.js.map +1 -0
- package/src/i18n/index.d.ts +3 -0
- package/src/i18n/index.d.ts.map +1 -0
- package/src/i18n/index.js +8 -0
- package/src/i18n/index.js.map +1 -0
- package/src/i18n/node-ecies-i18n-setup.d.ts +5 -0
- package/src/i18n/node-ecies-i18n-setup.d.ts.map +1 -0
- package/src/i18n/node-ecies-i18n-setup.js +48 -0
- package/src/i18n/node-ecies-i18n-setup.js.map +1 -0
- package/src/i18n/node-keys.d.ts +57 -0
- package/src/i18n/node-keys.d.ts.map +1 -0
- package/src/i18n/node-keys.js +67 -0
- package/src/i18n/node-keys.js.map +1 -0
- package/src/i18n/translations/de.d.ts +3 -0
- package/src/i18n/translations/de.d.ts.map +1 -0
- package/src/i18n/translations/de.js +57 -0
- package/src/i18n/translations/de.js.map +1 -0
- package/src/i18n/translations/en-GB.d.ts +3 -0
- package/src/i18n/translations/en-GB.d.ts.map +1 -0
- package/src/i18n/translations/en-GB.js +61 -0
- package/src/i18n/translations/en-GB.js.map +1 -0
- package/src/i18n/translations/en-US.d.ts +6 -0
- package/src/i18n/translations/en-US.d.ts.map +1 -0
- package/src/i18n/translations/en-US.js +65 -0
- package/src/i18n/translations/en-US.js.map +1 -0
- package/src/i18n/translations/es.d.ts +3 -0
- package/src/i18n/translations/es.d.ts.map +1 -0
- package/src/i18n/translations/es.js +57 -0
- package/src/i18n/translations/es.js.map +1 -0
- package/src/i18n/translations/fr.d.ts +3 -0
- package/src/i18n/translations/fr.d.ts.map +1 -0
- package/src/i18n/translations/fr.js +57 -0
- package/src/i18n/translations/fr.js.map +1 -0
- package/src/i18n/translations/index.d.ts +9 -0
- package/src/i18n/translations/index.d.ts.map +1 -0
- package/src/i18n/translations/index.js +20 -0
- package/src/i18n/translations/index.js.map +1 -0
- package/src/i18n/translations/ja.d.ts +3 -0
- package/src/i18n/translations/ja.d.ts.map +1 -0
- package/src/i18n/translations/ja.js +57 -0
- package/src/i18n/translations/ja.js.map +1 -0
- package/src/i18n/translations/uk.d.ts +3 -0
- package/src/i18n/translations/uk.d.ts.map +1 -0
- package/src/i18n/translations/uk.js +57 -0
- package/src/i18n/translations/uk.js.map +1 -0
- package/src/i18n/translations/zh-cn.d.ts +3 -0
- package/src/i18n/translations/zh-cn.d.ts.map +1 -0
- package/src/i18n/translations/zh-cn.js +57 -0
- package/src/i18n/translations/zh-cn.js.map +1 -0
- package/src/i18n-setup.d.ts +26 -0
- package/src/i18n-setup.d.ts.map +1 -0
- package/src/i18n-setup.js +111 -0
- package/src/i18n-setup.js.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +36 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/authenticated-cipher.d.ts +12 -0
- package/src/interfaces/authenticated-cipher.d.ts.map +1 -0
- package/src/interfaces/authenticated-cipher.js +3 -0
- package/src/interfaces/authenticated-cipher.js.map +1 -0
- package/src/interfaces/authenticated-decipher.d.ts +11 -0
- package/src/interfaces/authenticated-decipher.d.ts.map +1 -0
- package/src/interfaces/authenticated-decipher.js +3 -0
- package/src/interfaces/authenticated-decipher.js.map +1 -0
- package/src/interfaces/backend-member-operational.d.ts +48 -0
- package/src/interfaces/backend-member-operational.d.ts.map +1 -0
- package/src/interfaces/backend-member-operational.js +3 -0
- package/src/interfaces/backend-member-operational.js.map +1 -0
- package/src/interfaces/checksum-config.d.ts +5 -0
- package/src/interfaces/checksum-config.d.ts.map +1 -0
- package/src/interfaces/checksum-config.js +3 -0
- package/src/interfaces/checksum-config.js.map +1 -0
- package/src/interfaces/checksum-consts.d.ts +11 -0
- package/src/interfaces/checksum-consts.d.ts.map +1 -0
- package/src/interfaces/checksum-consts.js +3 -0
- package/src/interfaces/checksum-consts.js.map +1 -0
- package/src/interfaces/constants.d.ts +52 -0
- package/src/interfaces/constants.d.ts.map +1 -0
- package/src/interfaces/constants.js +3 -0
- package/src/interfaces/constants.js.map +1 -0
- package/src/interfaces/ecies-consts.d.ts +88 -0
- package/src/interfaces/ecies-consts.d.ts.map +1 -0
- package/src/interfaces/ecies-consts.js +3 -0
- package/src/interfaces/ecies-consts.js.map +1 -0
- package/src/interfaces/encrypted-chunk.d.ts +12 -0
- package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
- package/src/interfaces/encrypted-chunk.js +3 -0
- package/src/interfaces/encrypted-chunk.js.map +1 -0
- package/src/interfaces/encryption-consts.d.ts +11 -0
- package/src/interfaces/encryption-consts.d.ts.map +1 -0
- package/src/interfaces/encryption-consts.js +3 -0
- package/src/interfaces/encryption-consts.js.map +1 -0
- package/src/interfaces/index.d.ts +31 -0
- package/src/interfaces/index.d.ts.map +1 -0
- package/src/interfaces/index.js +33 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +6 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +1 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +3 -0
- package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +1 -0
- package/src/interfaces/keyring-consts.d.ts +6 -0
- package/src/interfaces/keyring-consts.d.ts.map +1 -0
- package/src/interfaces/keyring-consts.js +3 -0
- package/src/interfaces/keyring-consts.js.map +1 -0
- package/src/interfaces/member-with-mnemonic.d.ts +7 -0
- package/src/interfaces/member-with-mnemonic.d.ts.map +1 -0
- package/src/interfaces/member-with-mnemonic.js +3 -0
- package/src/interfaces/member-with-mnemonic.js.map +1 -0
- package/src/interfaces/member.d.ts +47 -0
- package/src/interfaces/member.d.ts.map +1 -0
- package/src/interfaces/member.js +3 -0
- package/src/interfaces/member.js.map +1 -0
- package/src/interfaces/multi-encrypted-message.d.ts +8 -0
- package/src/interfaces/multi-encrypted-message.d.ts.map +1 -0
- package/src/interfaces/multi-encrypted-message.js +3 -0
- package/src/interfaces/multi-encrypted-message.js.map +1 -0
- package/src/interfaces/multi-encrypted-parsed-header.d.ts +27 -0
- package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -0
- package/src/interfaces/multi-encrypted-parsed-header.js +3 -0
- package/src/interfaces/multi-encrypted-parsed-header.js.map +1 -0
- package/src/interfaces/multi-recipient-chunk.d.ts +26 -0
- package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
- package/src/interfaces/multi-recipient-chunk.js +15 -0
- package/src/interfaces/multi-recipient-chunk.js.map +1 -0
- package/src/interfaces/pbkdf-profiles.d.ts +6 -0
- package/src/interfaces/pbkdf-profiles.d.ts.map +1 -0
- package/src/interfaces/pbkdf-profiles.js +3 -0
- package/src/interfaces/pbkdf-profiles.js.map +1 -0
- package/src/interfaces/pbkdf2-result.d.ts +6 -0
- package/src/interfaces/pbkdf2-result.d.ts.map +1 -0
- package/src/interfaces/pbkdf2-result.js +3 -0
- package/src/interfaces/pbkdf2-result.js.map +1 -0
- package/src/interfaces/signing-key-private-key-info.d.ts +11 -0
- package/src/interfaces/signing-key-private-key-info.d.ts.map +1 -0
- package/src/interfaces/signing-key-private-key-info.js +3 -0
- package/src/interfaces/signing-key-private-key-info.js.map +1 -0
- package/src/interfaces/simple-keypair-buffer.d.ts +6 -0
- package/src/interfaces/simple-keypair-buffer.d.ts.map +1 -0
- package/src/interfaces/simple-keypair-buffer.js +3 -0
- package/src/interfaces/simple-keypair-buffer.js.map +1 -0
- package/src/interfaces/simple-keypair.d.ts +6 -0
- package/src/interfaces/simple-keypair.d.ts.map +1 -0
- package/src/interfaces/simple-keypair.js +3 -0
- package/src/interfaces/simple-keypair.js.map +1 -0
- package/src/interfaces/simple-public-key-only-buffer.d.ts +4 -0
- package/src/interfaces/simple-public-key-only-buffer.d.ts.map +1 -0
- package/src/interfaces/simple-public-key-only-buffer.js +3 -0
- package/src/interfaces/simple-public-key-only-buffer.js.map +1 -0
- package/src/interfaces/simple-public-key-only.d.ts +4 -0
- package/src/interfaces/simple-public-key-only.d.ts.map +1 -0
- package/src/interfaces/simple-public-key-only.js +3 -0
- package/src/interfaces/simple-public-key-only.js.map +1 -0
- package/src/interfaces/single-encrypted-parsed-header.d.ts +35 -0
- package/src/interfaces/single-encrypted-parsed-header.d.ts.map +1 -0
- package/src/interfaces/single-encrypted-parsed-header.js +3 -0
- package/src/interfaces/single-encrypted-parsed-header.js.map +1 -0
- package/src/interfaces/stream-config.d.ts +6 -0
- package/src/interfaces/stream-config.d.ts.map +1 -0
- package/src/interfaces/stream-config.js +8 -0
- package/src/interfaces/stream-config.js.map +1 -0
- package/src/interfaces/stream-progress.d.ts +22 -0
- package/src/interfaces/stream-progress.d.ts.map +1 -0
- package/src/interfaces/stream-progress.js +3 -0
- package/src/interfaces/stream-progress.js.map +1 -0
- package/src/interfaces/voting-consts.d.ts +86 -0
- package/src/interfaces/voting-consts.d.ts.map +1 -0
- package/src/interfaces/voting-consts.js +27 -0
- package/src/interfaces/voting-consts.js.map +1 -0
- package/src/interfaces/wallet-seed.d.ts +7 -0
- package/src/interfaces/wallet-seed.d.ts.map +1 -0
- package/src/interfaces/wallet-seed.js +3 -0
- package/src/interfaces/wallet-seed.js.map +1 -0
- package/src/interfaces/wrapped-key-consts.d.ts +7 -0
- package/src/interfaces/wrapped-key-consts.d.ts.map +1 -0
- package/src/interfaces/wrapped-key-consts.js +3 -0
- package/src/interfaces/wrapped-key-consts.js.map +1 -0
- package/src/isolated-private.d.ts +62 -0
- package/src/isolated-private.d.ts.map +1 -0
- package/src/isolated-private.js +139 -0
- package/src/isolated-private.js.map +1 -0
- package/src/isolated-public.d.ts +118 -0
- package/src/isolated-public.d.ts.map +1 -0
- package/src/isolated-public.js +317 -0
- package/src/isolated-public.js.map +1 -0
- package/src/lib/crypto-container.d.ts +13 -0
- package/src/lib/crypto-container.d.ts.map +1 -0
- package/src/lib/crypto-container.js +32 -0
- package/src/lib/crypto-container.js.map +1 -0
- package/src/lib/index.d.ts +4 -0
- package/src/lib/index.d.ts.map +1 -0
- package/src/lib/index.js +7 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/invariant-validator.d.ts +69 -0
- package/src/lib/invariant-validator.d.ts.map +1 -0
- package/src/lib/invariant-validator.js +98 -0
- package/src/lib/invariant-validator.js.map +1 -0
- package/src/lib/invariants/index.d.ts +8 -0
- package/src/lib/invariants/index.d.ts.map +1 -0
- package/src/lib/invariants/index.js +12 -0
- package/src/lib/invariants/index.js.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts +41 -0
- package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
- package/src/lib/invariants/recipient-id-consistency.js +75 -0
- package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
- package/src/member.d.ts +100 -0
- package/src/member.d.ts.map +1 -0
- package/src/member.js +345 -0
- package/src/member.js.map +1 -0
- package/src/services/aes-gcm.d.ts +66 -0
- package/src/services/aes-gcm.d.ts.map +1 -0
- package/src/services/aes-gcm.js +161 -0
- package/src/services/aes-gcm.js.map +1 -0
- package/src/services/chunk-processor.d.ts +15 -0
- package/src/services/chunk-processor.d.ts.map +1 -0
- package/src/services/chunk-processor.js +36 -0
- package/src/services/chunk-processor.js.map +1 -0
- package/src/services/ecies/crypto-core.d.ts +104 -0
- package/src/services/ecies/crypto-core.d.ts.map +1 -0
- package/src/services/ecies/crypto-core.js +234 -0
- package/src/services/ecies/crypto-core.js.map +1 -0
- package/src/services/ecies/file.d.ts +30 -0
- package/src/services/ecies/file.d.ts.map +1 -0
- package/src/services/ecies/file.js +112 -0
- package/src/services/ecies/file.js.map +1 -0
- package/src/services/ecies/index.d.ts +8 -0
- package/src/services/ecies/index.d.ts.map +1 -0
- package/src/services/ecies/index.js +11 -0
- package/src/services/ecies/index.js.map +1 -0
- package/src/services/ecies/multi-recipient.d.ts +84 -0
- package/src/services/ecies/multi-recipient.d.ts.map +1 -0
- package/src/services/ecies/multi-recipient.js +502 -0
- package/src/services/ecies/multi-recipient.js.map +1 -0
- package/src/services/ecies/service.d.ts +75 -0
- package/src/services/ecies/service.d.ts.map +1 -0
- package/src/services/ecies/service.js +152 -0
- package/src/services/ecies/service.js.map +1 -0
- package/src/services/ecies/signature.d.ts +38 -0
- package/src/services/ecies/signature.d.ts.map +1 -0
- package/src/services/ecies/signature.js +70 -0
- package/src/services/ecies/signature.js.map +1 -0
- package/src/services/ecies/single-recipient.d.ts +83 -0
- package/src/services/ecies/single-recipient.d.ts.map +1 -0
- package/src/services/ecies/single-recipient.js +452 -0
- package/src/services/ecies/single-recipient.js.map +1 -0
- package/src/services/ecies/utilities.d.ts +33 -0
- package/src/services/ecies/utilities.d.ts.map +1 -0
- package/src/services/ecies/utilities.js +91 -0
- package/src/services/ecies/utilities.js.map +1 -0
- package/src/services/encryption-stream.d.ts +33 -0
- package/src/services/encryption-stream.d.ts.map +1 -0
- package/src/services/encryption-stream.js +211 -0
- package/src/services/encryption-stream.js.map +1 -0
- package/src/services/index.d.ts +9 -0
- package/src/services/index.d.ts.map +1 -0
- package/src/services/index.js +14 -0
- package/src/services/index.js.map +1 -0
- package/src/services/multi-recipient-processor.d.ts +72 -0
- package/src/services/multi-recipient-processor.d.ts.map +1 -0
- package/src/services/multi-recipient-processor.js +325 -0
- package/src/services/multi-recipient-processor.js.map +1 -0
- package/src/services/pbkdf2.d.ts +105 -0
- package/src/services/pbkdf2.d.ts.map +1 -0
- package/src/services/pbkdf2.js +191 -0
- package/src/services/pbkdf2.js.map +1 -0
- package/src/services/progress-tracker.d.ts +14 -0
- package/src/services/progress-tracker.d.ts.map +1 -0
- package/src/services/progress-tracker.js +94 -0
- package/src/services/progress-tracker.js.map +1 -0
- package/src/services/voting.service.d.ts +262 -0
- package/src/services/voting.service.d.ts.map +1 -0
- package/src/services/voting.service.js +791 -0
- package/src/services/voting.service.js.map +1 -0
- package/src/test-mocks/index.d.ts +2 -0
- package/src/test-mocks/index.d.ts.map +1 -0
- package/src/test-mocks/index.js +5 -0
- package/src/test-mocks/index.js.map +1 -0
- package/src/test-mocks/mock-backend-member.d.ts +76 -0
- package/src/test-mocks/mock-backend-member.d.ts.map +1 -0
- package/src/test-mocks/mock-backend-member.js +139 -0
- package/src/test-mocks/mock-backend-member.js.map +1 -0
- package/src/testing.d.ts +2 -0
- package/src/testing.d.ts.map +1 -0
- package/src/testing.js +6 -0
- package/src/testing.js.map +1 -0
- package/src/types/id-guards.d.ts +39 -0
- package/src/types/id-guards.d.ts.map +1 -0
- package/src/types/id-guards.js +91 -0
- package/src/types/id-guards.js.map +1 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +5 -0
- package/src/types/index.js.map +1 -0
- package/src/types.d.ts +26 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +6 -0
- package/src/types.js.map +1 -0
- package/src/utils.d.ts +11 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.js +82 -0
- package/src/utils.js.map +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress information for streaming operations
|
|
3
|
+
*/
|
|
4
|
+
export interface IStreamProgress {
|
|
5
|
+
/** Total bytes processed so far */
|
|
6
|
+
bytesProcessed: number;
|
|
7
|
+
/** Total bytes to process (undefined for unknown-length streams) */
|
|
8
|
+
totalBytes?: number;
|
|
9
|
+
/** Number of chunks processed */
|
|
10
|
+
chunksProcessed: number;
|
|
11
|
+
/** Percentage complete (0-100, undefined if totalBytes unknown) */
|
|
12
|
+
percentComplete?: number;
|
|
13
|
+
/** Current throughput in bytes per second */
|
|
14
|
+
throughputBytesPerSec: number;
|
|
15
|
+
/** Estimated time remaining in seconds (undefined if totalBytes unknown) */
|
|
16
|
+
estimatedTimeRemaining?: number;
|
|
17
|
+
/** Timestamp when operation started */
|
|
18
|
+
startTime: number;
|
|
19
|
+
/** Elapsed time in milliseconds */
|
|
20
|
+
elapsedTime: number;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=stream-progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-progress.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/stream-progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,4EAA4E;IAC5E,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-progress.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/stream-progress.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for voting operations using Paillier homomorphic encryption.
|
|
3
|
+
* These values are critical for cryptographic operations and should be consistent
|
|
4
|
+
* across all implementations (ecies-lib, node-ecies-lib, BrightChain).
|
|
5
|
+
*
|
|
6
|
+
* This file is separated from voting.service.ts to avoid circular dependencies
|
|
7
|
+
* with isolated-public.ts and isolated-private.ts.
|
|
8
|
+
*/
|
|
9
|
+
export interface IVotingConsts {
|
|
10
|
+
/**
|
|
11
|
+
* Info string used in HKDF for prime generation.
|
|
12
|
+
* This provides domain separation in the key derivation process.
|
|
13
|
+
*/
|
|
14
|
+
readonly PRIME_GEN_INFO: 'PaillierPrimeGen';
|
|
15
|
+
/**
|
|
16
|
+
* Number of iterations for Miller-Rabin primality test.
|
|
17
|
+
* With 256 rounds, probability of false positive is < 2^-512.
|
|
18
|
+
*/
|
|
19
|
+
readonly PRIME_TEST_ITERATIONS: 256;
|
|
20
|
+
/**
|
|
21
|
+
* Bit length for Paillier key pair generation.
|
|
22
|
+
* 3072 bits provides ~128-bit security level (NIST recommended).
|
|
23
|
+
*/
|
|
24
|
+
readonly KEYPAIR_BIT_LENGTH: 3072;
|
|
25
|
+
/**
|
|
26
|
+
* Offset of the public key in the key pair buffer.
|
|
27
|
+
* Used for buffer serialization calculations.
|
|
28
|
+
*/
|
|
29
|
+
readonly PUB_KEY_OFFSET: 768;
|
|
30
|
+
/**
|
|
31
|
+
* HKDF output length in bytes.
|
|
32
|
+
* SHA-512 produces 64 bytes.
|
|
33
|
+
*/
|
|
34
|
+
readonly HKDF_LENGTH: 64;
|
|
35
|
+
/**
|
|
36
|
+
* HMAC algorithm for HKDF key derivation.
|
|
37
|
+
*/
|
|
38
|
+
readonly HMAC_ALGORITHM: 'sha512';
|
|
39
|
+
/**
|
|
40
|
+
* Hash algorithm for key ID generation and HMAC tagging.
|
|
41
|
+
*/
|
|
42
|
+
readonly HASH_ALGORITHM: 'sha256';
|
|
43
|
+
/**
|
|
44
|
+
* Radix for bit string representation (binary).
|
|
45
|
+
*/
|
|
46
|
+
readonly BITS_RADIX: 2;
|
|
47
|
+
/**
|
|
48
|
+
* Radix for key serialization (hexadecimal).
|
|
49
|
+
*/
|
|
50
|
+
readonly KEY_RADIX: 16;
|
|
51
|
+
/**
|
|
52
|
+
* Format for key serialization.
|
|
53
|
+
*/
|
|
54
|
+
readonly KEY_FORMAT: 'hex';
|
|
55
|
+
/**
|
|
56
|
+
* Format for digest output.
|
|
57
|
+
*/
|
|
58
|
+
readonly DIGEST_FORMAT: 'hex';
|
|
59
|
+
/**
|
|
60
|
+
* Version number for key serialization format.
|
|
61
|
+
*/
|
|
62
|
+
readonly KEY_VERSION: 1;
|
|
63
|
+
/**
|
|
64
|
+
* Magic bytes for identifying BrightChain voting keys.
|
|
65
|
+
*/
|
|
66
|
+
readonly KEY_MAGIC: 'BCVK';
|
|
67
|
+
/**
|
|
68
|
+
* Maximum attempts to generate a valid prime in DRBG.
|
|
69
|
+
*/
|
|
70
|
+
readonly DRBG_PRIME_ATTEMPTS: 20000;
|
|
71
|
+
/**
|
|
72
|
+
* Length of key ID in bytes (SHA-256 output).
|
|
73
|
+
*/
|
|
74
|
+
readonly KEY_ID_LENGTH: 32;
|
|
75
|
+
/**
|
|
76
|
+
* Length of instance ID in bytes (SHA-256 output).
|
|
77
|
+
*/
|
|
78
|
+
readonly INSTANCE_ID_LENGTH: 32;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Constants for voting operations using Paillier homomorphic encryption.
|
|
82
|
+
* These values are critical for cryptographic operations and MUST match
|
|
83
|
+
* across all implementations (ecies-lib, node-ecies-lib, BrightChain).
|
|
84
|
+
*/
|
|
85
|
+
export declare const VOTING: IVotingConsts;
|
|
86
|
+
//# sourceMappingURL=voting-consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-consts.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/voting-consts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAElC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,EAAE,aAiBnB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VOTING = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Constants for voting operations using Paillier homomorphic encryption.
|
|
6
|
+
* These values are critical for cryptographic operations and MUST match
|
|
7
|
+
* across all implementations (ecies-lib, node-ecies-lib, BrightChain).
|
|
8
|
+
*/
|
|
9
|
+
exports.VOTING = Object.freeze({
|
|
10
|
+
PRIME_GEN_INFO: 'PaillierPrimeGen',
|
|
11
|
+
PRIME_TEST_ITERATIONS: 256,
|
|
12
|
+
KEYPAIR_BIT_LENGTH: 3072,
|
|
13
|
+
PUB_KEY_OFFSET: 768,
|
|
14
|
+
HKDF_LENGTH: 64,
|
|
15
|
+
HMAC_ALGORITHM: 'sha512',
|
|
16
|
+
HASH_ALGORITHM: 'sha256',
|
|
17
|
+
BITS_RADIX: 2,
|
|
18
|
+
KEY_RADIX: 16,
|
|
19
|
+
KEY_FORMAT: 'hex',
|
|
20
|
+
DIGEST_FORMAT: 'hex',
|
|
21
|
+
KEY_VERSION: 1,
|
|
22
|
+
KEY_MAGIC: 'BCVK',
|
|
23
|
+
DRBG_PRIME_ATTEMPTS: 20000,
|
|
24
|
+
KEY_ID_LENGTH: 32,
|
|
25
|
+
INSTANCE_ID_LENGTH: 32,
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=voting-consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-consts.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/voting-consts.ts"],"names":[],"mappings":";;;AA+FA;;;;GAIG;AACU,QAAA,MAAM,GAAkB,MAAM,CAAC,MAAM,CAAC;IACjD,cAAc,EAAE,kBAA2B;IAC3C,qBAAqB,EAAE,GAAY;IACnC,kBAAkB,EAAE,IAAa;IACjC,cAAc,EAAE,GAAY;IAC5B,WAAW,EAAE,EAAW;IACxB,cAAc,EAAE,QAAiB;IACjC,cAAc,EAAE,QAAiB;IACjC,UAAU,EAAE,CAAU;IACtB,SAAS,EAAE,EAAW;IACtB,UAAU,EAAE,KAAc;IAC1B,aAAa,EAAE,KAAc;IAC7B,WAAW,EAAE,CAAU;IACvB,SAAS,EAAE,MAAe;IAC1B,mBAAmB,EAAE,KAAc;IACnC,aAAa,EAAE,EAAW;IAC1B,kBAAkB,EAAE,EAAW;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-seed.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/wallet-seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-seed.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/wallet-seed.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapped-key-consts.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/wrapped-key-consts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapped-key-consts.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/interfaces/wrapped-key-consts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IIsolatedPrivateKey } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { PrivateKey } from 'paillier-bigint';
|
|
3
|
+
import { IsolatedPublicKey } from './isolated-public';
|
|
4
|
+
/**
|
|
5
|
+
* IsolatedPrivateKey extends Paillier PrivateKey with instance isolation validation.
|
|
6
|
+
*
|
|
7
|
+
* This class ensures that:
|
|
8
|
+
* - Decryption only works with ciphertexts encrypted by the matching IsolatedPublicKey instance
|
|
9
|
+
* - Instance ID verification prevents cross-instance decryption attacks
|
|
10
|
+
* - HMAC validation ensures ciphertext integrity
|
|
11
|
+
*
|
|
12
|
+
* The private key stores the original keyId and instanceId from construction time,
|
|
13
|
+
* and validates them before any decryption operation.
|
|
14
|
+
*/
|
|
15
|
+
export declare class IsolatedPrivateKey extends PrivateKey implements IIsolatedPrivateKey<Buffer, 'sync'> {
|
|
16
|
+
/**
|
|
17
|
+
* Original keyId from the IsolatedPublicKey at construction time
|
|
18
|
+
*/
|
|
19
|
+
private readonly _originalKeyId;
|
|
20
|
+
/**
|
|
21
|
+
* Original instanceId from the IsolatedPublicKey at construction time
|
|
22
|
+
*/
|
|
23
|
+
private readonly _originalInstanceId;
|
|
24
|
+
/**
|
|
25
|
+
* Reference to the original IsolatedPublicKey
|
|
26
|
+
*/
|
|
27
|
+
private readonly _originalPublicKey;
|
|
28
|
+
constructor(lambda: bigint, mu: bigint, publicKey: IsolatedPublicKey);
|
|
29
|
+
/**
|
|
30
|
+
* Converts hex string to Buffer
|
|
31
|
+
*/
|
|
32
|
+
private hexToBuffer;
|
|
33
|
+
/**
|
|
34
|
+
* Converts Buffer to hex string
|
|
35
|
+
*/
|
|
36
|
+
private bufferToHex;
|
|
37
|
+
/**
|
|
38
|
+
* Compares two Buffers for equality
|
|
39
|
+
*/
|
|
40
|
+
private bufferEquals;
|
|
41
|
+
/**
|
|
42
|
+
* Decrypts a tagged ciphertext after validating instance ID and HMAC
|
|
43
|
+
*/
|
|
44
|
+
decryptIsolated(taggedCiphertext: bigint): bigint;
|
|
45
|
+
/**
|
|
46
|
+
* Synchronous decrypt override (throws error - use decryptIsolated instead)
|
|
47
|
+
*/
|
|
48
|
+
decrypt(_taggedCiphertext: bigint): bigint;
|
|
49
|
+
/**
|
|
50
|
+
* Gets a copy of the original keyId
|
|
51
|
+
*/
|
|
52
|
+
getOriginalKeyId(): Buffer;
|
|
53
|
+
/**
|
|
54
|
+
* Gets a copy of the original instanceId
|
|
55
|
+
*/
|
|
56
|
+
getOriginalInstanceId(): Buffer;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the original public key reference
|
|
59
|
+
*/
|
|
60
|
+
getOriginalPublicKey(): IsolatedPublicKey;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=isolated-private.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-private.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/isolated-private.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAa,MAAM,iBAAiB,CAAC;AAKxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,qBAAa,kBACX,SAAQ,UACR,YAAW,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC;IAE9C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAE7C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;gBAE3C,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB;IAepE;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACI,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM;IAsDxD;;OAEG;IAEM,OAAO,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM;IAInD;;OAEG;IACI,gBAAgB,IAAI,MAAM;IAIjC;;OAEG;IACI,qBAAqB,IAAI,MAAM;IAItC;;OAEG;IACI,oBAAoB,IAAI,iBAAiB;CAGjD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsolatedPrivateKey = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const paillier_bigint_1 = require("paillier-bigint");
|
|
6
|
+
const voting_error_type_1 = require("./enumerations/voting-error-type");
|
|
7
|
+
const voting_1 = require("./errors/voting");
|
|
8
|
+
const voting_consts_1 = require("./interfaces/voting-consts");
|
|
9
|
+
const isolated_public_1 = require("./isolated-public");
|
|
10
|
+
/**
|
|
11
|
+
* IsolatedPrivateKey extends Paillier PrivateKey with instance isolation validation.
|
|
12
|
+
*
|
|
13
|
+
* This class ensures that:
|
|
14
|
+
* - Decryption only works with ciphertexts encrypted by the matching IsolatedPublicKey instance
|
|
15
|
+
* - Instance ID verification prevents cross-instance decryption attacks
|
|
16
|
+
* - HMAC validation ensures ciphertext integrity
|
|
17
|
+
*
|
|
18
|
+
* The private key stores the original keyId and instanceId from construction time,
|
|
19
|
+
* and validates them before any decryption operation.
|
|
20
|
+
*/
|
|
21
|
+
class IsolatedPrivateKey extends paillier_bigint_1.PrivateKey {
|
|
22
|
+
/**
|
|
23
|
+
* Original keyId from the IsolatedPublicKey at construction time
|
|
24
|
+
*/
|
|
25
|
+
_originalKeyId;
|
|
26
|
+
/**
|
|
27
|
+
* Original instanceId from the IsolatedPublicKey at construction time
|
|
28
|
+
*/
|
|
29
|
+
_originalInstanceId;
|
|
30
|
+
/**
|
|
31
|
+
* Reference to the original IsolatedPublicKey
|
|
32
|
+
*/
|
|
33
|
+
_originalPublicKey;
|
|
34
|
+
constructor(lambda, mu, publicKey) {
|
|
35
|
+
if (!isolated_public_1.IsolatedPublicKey.isIsolatedPublicKey(publicKey)) {
|
|
36
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.InvalidPublicKeyFormat);
|
|
37
|
+
}
|
|
38
|
+
// Create a base PublicKey instance for the parent constructor
|
|
39
|
+
const basePublicKey = new paillier_bigint_1.PublicKey(publicKey.n, publicKey.g);
|
|
40
|
+
super(lambda, mu, basePublicKey);
|
|
41
|
+
// Store the isolated public key for our own use
|
|
42
|
+
this._originalKeyId = publicKey.getKeyId();
|
|
43
|
+
this._originalInstanceId = publicKey.getInstanceId();
|
|
44
|
+
this._originalPublicKey = publicKey;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts hex string to Buffer
|
|
48
|
+
*/
|
|
49
|
+
hexToBuffer(hex) {
|
|
50
|
+
if (hex.length % 2 !== 0) {
|
|
51
|
+
hex = '0' + hex;
|
|
52
|
+
}
|
|
53
|
+
return Buffer.from(hex, 'hex');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Converts Buffer to hex string
|
|
57
|
+
*/
|
|
58
|
+
bufferToHex(bytes) {
|
|
59
|
+
return bytes.toString('hex');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Compares two Buffers for equality
|
|
63
|
+
*/
|
|
64
|
+
bufferEquals(a, b) {
|
|
65
|
+
return Buffer.compare(a, b) === 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Decrypts a tagged ciphertext after validating instance ID and HMAC
|
|
69
|
+
*/
|
|
70
|
+
decryptIsolated(taggedCiphertext) {
|
|
71
|
+
// First verify if we're using a recovered key by checking the public key instance
|
|
72
|
+
if (!isolated_public_1.IsolatedPublicKey.isIsolatedPublicKey(this._originalPublicKey)) {
|
|
73
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.InvalidPublicKeyFormat);
|
|
74
|
+
}
|
|
75
|
+
// Compare instance IDs before any ciphertext operations
|
|
76
|
+
const currentInstanceId = this._originalPublicKey.getInstanceId();
|
|
77
|
+
// This check must happen before any ciphertext operations
|
|
78
|
+
if (!this.bufferEquals(currentInstanceId, this._originalInstanceId)) {
|
|
79
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.InstanceIdMismatch);
|
|
80
|
+
}
|
|
81
|
+
// Now that we've verified the instance ID, we can proceed with ciphertext operations
|
|
82
|
+
try {
|
|
83
|
+
const hmacLength = 64;
|
|
84
|
+
const ciphertextString = taggedCiphertext.toString(voting_consts_1.VOTING.KEY_RADIX);
|
|
85
|
+
const receivedHmac = ciphertextString.slice(-hmacLength);
|
|
86
|
+
const ciphertextHex = ciphertextString.slice(0, -hmacLength);
|
|
87
|
+
const ciphertextBigInt = BigInt(`0x${ciphertextHex}`);
|
|
88
|
+
// Create HMAC key from originalKeyId + originalInstanceId
|
|
89
|
+
const hmacKeyMaterial = Buffer.concat([
|
|
90
|
+
this._originalKeyId,
|
|
91
|
+
this._originalInstanceId,
|
|
92
|
+
]);
|
|
93
|
+
// Calculate expected HMAC
|
|
94
|
+
const ciphertextBytes = Buffer.from(ciphertextBigInt.toString(voting_consts_1.VOTING.KEY_RADIX), 'utf8');
|
|
95
|
+
const hmac = (0, crypto_1.createHmac)('sha256', hmacKeyMaterial);
|
|
96
|
+
hmac.update(ciphertextBytes);
|
|
97
|
+
const expectedHmac = this.bufferToHex(hmac.digest());
|
|
98
|
+
// Verify HMAC
|
|
99
|
+
if (receivedHmac !== expectedHmac) {
|
|
100
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.InvalidCiphertextHmac);
|
|
101
|
+
}
|
|
102
|
+
// Finally decrypt the ciphertext using the parent class implementation
|
|
103
|
+
return super.decrypt(ciphertextBigInt);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof voting_1.VotingError) {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.InvalidPrivateKeyBufferFailedToParse);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Synchronous decrypt override (throws error - use decryptIsolated instead)
|
|
114
|
+
*/
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
116
|
+
decrypt(_taggedCiphertext) {
|
|
117
|
+
throw new voting_1.VotingError(voting_error_type_1.VotingErrorType.KeyPairValidationFailed);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Gets a copy of the original keyId
|
|
121
|
+
*/
|
|
122
|
+
getOriginalKeyId() {
|
|
123
|
+
return Buffer.from(this._originalKeyId);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Gets a copy of the original instanceId
|
|
127
|
+
*/
|
|
128
|
+
getOriginalInstanceId() {
|
|
129
|
+
return Buffer.from(this._originalInstanceId);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Gets the original public key reference
|
|
133
|
+
*/
|
|
134
|
+
getOriginalPublicKey() {
|
|
135
|
+
return this._originalPublicKey;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.IsolatedPrivateKey = IsolatedPrivateKey;
|
|
139
|
+
//# sourceMappingURL=isolated-private.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-private.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-ecies-lib/src/isolated-private.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAGpC,qDAAwD;AAExD,wEAAmE;AACnE,4CAA8C;AAC9C,8DAAoD;AACpD,uDAAsD;AAEtD;;;;;;;;;;GAUG;AACH,MAAa,kBACX,SAAQ,4BAAU;IAGlB;;OAEG;IACc,cAAc,CAAS;IAExC;;OAEG;IACc,mBAAmB,CAAS;IAE7C;;OAEG;IACc,kBAAkB,CAAoB;IAEvD,YAAY,MAAc,EAAE,EAAU,EAAE,SAA4B;QAClE,IAAI,CAAC,mCAAiB,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,oBAAW,CAAC,mCAAe,CAAC,sBAAsB,CAAC,CAAC;QAChE,CAAC;QAED,8DAA8D;QAC9D,MAAM,aAAa,GAAG,IAAI,2BAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9D,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;QAEjC,gDAAgD;QAChD,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC3C,IAAI,CAAC,mBAAmB,GA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OAEG;IACI,gBAAgB;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACI,qBAAqB;QAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,oBAAoB;QACzB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;CACF;AA/ID,gDA+IC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { IIsolatedPublicKey } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { PublicKey } from 'paillier-bigint';
|
|
3
|
+
/**
|
|
4
|
+
* IsolatedPublicKey extends Paillier PublicKey with instance isolation capabilities.
|
|
5
|
+
*
|
|
6
|
+
* This class provides:
|
|
7
|
+
* - keyId: A deterministic SHA-256 hash of the public key 'n' value for verification
|
|
8
|
+
* - instanceId: A unique identifier per key instance to prevent cross-instance operations
|
|
9
|
+
* - HMAC-tagged ciphertexts that bind encrypted values to a specific key instance
|
|
10
|
+
*
|
|
11
|
+
* Instance isolation ensures that ciphertexts encrypted with one instance cannot be
|
|
12
|
+
* used with another instance, even if they share the same underlying key material.
|
|
13
|
+
* This is critical for voting systems where ballot tampering must be prevented.
|
|
14
|
+
*/
|
|
15
|
+
export declare class IsolatedPublicKey extends PublicKey implements IIsolatedPublicKey<Buffer, 'sync'> {
|
|
16
|
+
/**
|
|
17
|
+
* Type guard to check if a PublicKey is an IsolatedPublicKey
|
|
18
|
+
*/
|
|
19
|
+
static isIsolatedPublicKey(key: PublicKey): key is IsolatedPublicKey;
|
|
20
|
+
/**
|
|
21
|
+
* Deterministic identifier derived from the public key (SHA-256 of 'n')
|
|
22
|
+
*/
|
|
23
|
+
readonly keyId: Buffer;
|
|
24
|
+
/**
|
|
25
|
+
* Original instance ID generated at construction time
|
|
26
|
+
*/
|
|
27
|
+
private readonly _originalInstanceId;
|
|
28
|
+
/**
|
|
29
|
+
* Current instance ID (can be updated via updateInstanceId())
|
|
30
|
+
*/
|
|
31
|
+
private _currentInstanceId;
|
|
32
|
+
/**
|
|
33
|
+
* Unique salt used for instance ID generation
|
|
34
|
+
*/
|
|
35
|
+
private readonly uniqueInstanceSalt;
|
|
36
|
+
/**
|
|
37
|
+
* Updates the current instance ID to a new random value.
|
|
38
|
+
* This invalidates all previously encrypted ciphertexts.
|
|
39
|
+
*/
|
|
40
|
+
updateInstanceId(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Generates a deterministic instance ID from keyId, n, and a unique salt
|
|
43
|
+
*/
|
|
44
|
+
private generateInstanceId;
|
|
45
|
+
/**
|
|
46
|
+
* SHA-256 hash using Node.js crypto
|
|
47
|
+
*/
|
|
48
|
+
private sha256;
|
|
49
|
+
/**
|
|
50
|
+
* Converts hex string to Buffer
|
|
51
|
+
*/
|
|
52
|
+
private hexToBuffer;
|
|
53
|
+
/**
|
|
54
|
+
* Converts Buffer to hex string
|
|
55
|
+
*/
|
|
56
|
+
private bufferToHex;
|
|
57
|
+
constructor(n: bigint, g: bigint, keyId: Buffer);
|
|
58
|
+
/**
|
|
59
|
+
* Static factory method to create IsolatedPublicKey synchronously
|
|
60
|
+
*/
|
|
61
|
+
static create(n: bigint, g: bigint, keyId: Buffer): IsolatedPublicKey;
|
|
62
|
+
/**
|
|
63
|
+
* Static factory method to create IsolatedPublicKey from deserialized data
|
|
64
|
+
* Used when reconstructing a key from a buffer with a stored instanceId
|
|
65
|
+
*/
|
|
66
|
+
static fromBuffer(n: bigint, g: bigint, keyId: Buffer, instanceId: Buffer): IsolatedPublicKey;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a copy of the keyId
|
|
69
|
+
*/
|
|
70
|
+
getKeyId(): Buffer;
|
|
71
|
+
/**
|
|
72
|
+
* Returns a copy of the current instance ID
|
|
73
|
+
*/
|
|
74
|
+
getInstanceId(): Buffer;
|
|
75
|
+
/**
|
|
76
|
+
* Tags a ciphertext with an HMAC using keyId + instanceId
|
|
77
|
+
* Returns a new bigint with the HMAC appended
|
|
78
|
+
*/
|
|
79
|
+
private tagCiphertext;
|
|
80
|
+
/**
|
|
81
|
+
* Extracts and validates the instance ID from a tagged ciphertext
|
|
82
|
+
* Returns the instance ID if valid, or zero-filled buffer if invalid
|
|
83
|
+
*/
|
|
84
|
+
extractInstanceId(ciphertext: bigint): Buffer;
|
|
85
|
+
/**
|
|
86
|
+
* Encrypts a message and tags it with instance HMAC
|
|
87
|
+
*/
|
|
88
|
+
encryptIsolated(m: bigint): bigint;
|
|
89
|
+
/**
|
|
90
|
+
* Synchronous encrypt override (throws error - use encryptIsolated instead)
|
|
91
|
+
*/
|
|
92
|
+
encrypt(_m: bigint): bigint;
|
|
93
|
+
/**
|
|
94
|
+
* Multiplies a ciphertext by a constant, preserving instance HMAC
|
|
95
|
+
*/
|
|
96
|
+
multiplyIsolated(ciphertext: bigint, constant: bigint): bigint;
|
|
97
|
+
/**
|
|
98
|
+
* Synchronous multiply override (throws error - use multiplyIsolated instead)
|
|
99
|
+
*/
|
|
100
|
+
multiply(_ciphertext: bigint, _constant: bigint): bigint;
|
|
101
|
+
/**
|
|
102
|
+
* Adds two ciphertexts, preserving instance HMAC
|
|
103
|
+
*/
|
|
104
|
+
additionIsolated(a: bigint, b: bigint): bigint;
|
|
105
|
+
/**
|
|
106
|
+
* Synchronous addition override (throws error - use additionIsolated instead)
|
|
107
|
+
*/
|
|
108
|
+
addition(_a: bigint, _b: bigint): bigint;
|
|
109
|
+
/**
|
|
110
|
+
* Verifies that the keyId matches the SHA-256 hash of the public key 'n'
|
|
111
|
+
*/
|
|
112
|
+
verifyKeyId(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Compares two Buffers for equality
|
|
115
|
+
*/
|
|
116
|
+
private bufferEquals;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=isolated-public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated-public.d.ts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