Skip to content

Commit daa202a

Browse files
committed
fix: secret expose projective point intead of affine for marshalling
1 parent a305652 commit daa202a

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "identity-based-encryption-bn254",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"source": "src/index.ts",
55
"main": "./dist/cjs/index.cjs",
66
"module": "./dist/esm/index.mjs",

src/ibe.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class IBE {
1313

1414
createDecryptionKey(secretKey: SecretKey | Uint8Array, identity: Identity): DecryptionKey {
1515
const sk = secretKey instanceof Uint8Array ? bn254.fields.Fr.fromBytes(secretKey) : secretKey.sk
16-
return {k: identity.i.multiply(sk).toAffine()}
16+
return {k: identity.i.multiply(sk)}
1717
}
1818

1919
encrypt(message: Uint8Array, identity: Identity, publicKey: PublicKey) {
@@ -23,7 +23,7 @@ export class IBE {
2323
decrypt(ciphertext: Ciphertext, decryptionKey: DecryptionKey | Uint8Array): Uint8Array {
2424
try {
2525
const key = decryptionKey instanceof Uint8Array ? bn254.G1.ProjectivePoint.fromHex(decryptionKey) : decryptionKey.k
26-
return decrypt(ciphertext, key, this.opts)
26+
return decrypt(ciphertext, key.toAffine(), this.opts)
2727
} catch (err) {
2828
throw new Error("failed to decrypt the ciphertext - did you use the correct key?")
2929
}
@@ -60,5 +60,5 @@ export type PublicKey = {
6060
}
6161

6262
export type DecryptionKey = {
63-
k: G1
63+
k: ProjPointType<Fp>
6464
}

src/serde.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as asn1js from "asn1js"
22
import {bn254} from "@kevincharm/noble-bn254-drand"
3-
import {Ciphertext} from "./crypto"
3+
import {Ciphertext, G2} from "./crypto"
4+
import {ProjPointType} from "@noble/curves/esm/abstract/weierstrass"
5+
import {Fp} from "@noble/curves/esm/abstract/tower"
46

57
/**
68
* Serialize Ciphertext to ASN.1 structure

0 commit comments

Comments
 (0)