forked from nucypher/rust-umbral
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
/* | ||
contents added by umbral-pre-wasm makefile/build script | ||
*/ | ||
|
||
import { KeyFrag, encryptPlaintext } from "./umbral_pre_wasm_bg.js"; | ||
|
||
export const decrypt_reencrypted = ( | ||
receiving_sk,//: SecretKey, | ||
delegating_pk,//: PublicKey, | ||
capsule,//: Capsule, | ||
verified_cfrags,//: Sequence[VerifiedCapsuleFrag], | ||
ciphertext//: bytes,) => ( | ||
) => { | ||
const capsuleWithCFrags = verified_cfrags.reduce((value, cfrag) => { | ||
return value.withCFrag(cfrag) | ||
}, capsule) | ||
return capsuleWithCFrags.decryptReencrypted(receiving_sk, delegating_pk, ciphertext); | ||
} | ||
|
||
export function encrypt(delegating_pk, plaintext) { | ||
const encryptionResult = encryptPlaintext(delegating_pk, plaintext) | ||
return { | ||
capsule: encryptionResult.capsule, | ||
ciphertext: encryptionResult.ciphertext | ||
} | ||
} | ||
|
||
KeyFrag.prototype.verify = (verifying_pk, optional = {delegating_pk, receiving_pk} = {}) => { | ||
const delegating_pk = optional.delegating_pk | ||
const receiving_pk = optional.receiving_pk | ||
|
||
if (receiving_pk && delegating_pk) { | ||
return this.verifyWithDelegatingAndReceivingKeys(verifying_pk, delegating_pk, receiving_pk) | ||
} | ||
|
||
if (receiving_pk){ | ||
return this.verifyWithReceivingKey(verifying_pk, receiving_pk) | ||
} | ||
|
||
if (delegating_pk){ | ||
return this.verifyWithDelegatingKey(verifying_pk, delegating_pk) | ||
} | ||
|
||
return this.verify_with_only_public_key() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters