-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API tweaks/hacks after build #66
Conversation
umbral-pre-wasm/Makefile
Outdated
@@ -23,6 +23,9 @@ pkg: src | |||
cp package.template.json pkg/package.json | |||
cp LICENSE README.md pkg/ | |||
|
|||
# add patches | |||
cat ./patches/api-compatibility.js.txt >> pkg/pkg-bundler/umbral_pre_wasm.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have to be a .txt
? It's a minor thing, but we're losing the syntax coloring in diffs, and the editors won't pick up the language automatically too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be anything, I just wanted to be clear that it isn't actually executable in this context, but that's not too important.
return this.verifyWithDelegatingKey(verifying_pk, delegating_pk) | ||
} | ||
|
||
return this.verify_with_only_public_key() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it take verifying_pk
here?
umbral-pre-wasm/src/lib.rs
Outdated
@@ -393,7 +393,7 @@ impl KeyFrag { | |||
// So we have to use 4 functions instead of 1. Yikes. | |||
|
|||
#[wasm_bindgen] | |||
pub fn verify(&self, verifying_pk: &PublicKey) -> Result<VerifiedKeyFrag, JsValue> { | |||
pub fn verify_with_only_public_key(&self, verifying_pk: &PublicKey) -> Result<VerifiedKeyFrag, JsValue> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use #[wasm_bindgen(js_name = verifyWithOnlyPublicKey)]
tag before the method definition to make the name camel-case in JS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "with_only_verifying_key" for the name? I know it sounds like a tautology, but "public key" seems too vague.
return capsuleWithCFrags.decryptReencrypted(receiving_sk, delegating_pk, ciphertext); | ||
} | ||
|
||
KeyFrag.prototype.verify = (verifying_pk, optional = {delegating_pk, receiving_pk} = {}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting construction here - optional = {delegating_pk, receiving_pk} = {}
. Does it means that it checks that the given dictionary can only have keys with these names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so you'd call it like
kfrag.verify(pk)
in which case the default value of {} would be passed in.
but you could call it like kfrag.verify(pk, {delegating_pk, receiving_pk})
the nice thing is that inside the method, testing optional.delegating_pk
will work.
I think @piotr-roslaniec came up with this if I remember correctly.
import { KeyFrag } from "./umbral_pre_wasm_bg.js"; | ||
|
||
export const decrypt_reencrypted = ( | ||
receiving_sk,//: SecretKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the comments can be removed, or at least cleaned up a little
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## master #66 +/- ##
===========================================
- Coverage 81.16% 68.81% -12.35%
===========================================
Files 15 16 +1
Lines 1120 1321 +201
===========================================
Hits 909 909
- Misses 211 412 +201
Continue to review full report at Codecov.
|
enables API changes as seen here:
vepkenez/umbral-pre-react-example@a714bc3