Comparing version 0.0.74 to 0.0.75
@@ -76,5 +76,5 @@ import { check } from "./system"; | ||
export class ECCPublicKey implements Packer { | ||
data: Array<u8> | null; | ||
constructor(data: u8[] | null = null) { | ||
constructor( | ||
public data: u8[] | null = null | ||
) { | ||
if (data) { | ||
@@ -125,2 +125,51 @@ check(data.length == 33, "bad data size"); | ||
export class ECCUncompressedPublicKey implements Packer { | ||
constructor( | ||
public data: u8[] | null = null | ||
) { | ||
if (data) { | ||
check(data.length == 65, "bad data size"); | ||
} | ||
this.data = data; | ||
} | ||
pack(): u8[] { | ||
return this.data!; | ||
} | ||
unpack(data: u8[]): usize { | ||
let dec = new Decoder(data); | ||
this.data = dec.unpackBytes(65); | ||
return 65; | ||
} | ||
getSize(): usize { | ||
return 65; | ||
} | ||
toString(): string { | ||
return Utils.bytesToHex(this.data!); | ||
} | ||
@inline @operator('==') | ||
static eq(a: ECCUncompressedPublicKey, b: ECCUncompressedPublicKey): bool { | ||
return Utils.bytesCmp(a.data!, b.data!) == 0; | ||
} | ||
@inline @operator('!=') | ||
static neq(a: ECCUncompressedPublicKey, b: ECCUncompressedPublicKey): bool { | ||
return Utils.bytesCmp(a.data!, b.data!) != 0; | ||
} | ||
@inline @operator('>') | ||
static gt(a: ECCUncompressedPublicKey, b: ECCUncompressedPublicKey): bool { | ||
return Utils.bytesCmp(a.data!, b.data!) > 0; | ||
} | ||
@inline @operator('<') | ||
static lt(a: ECCUncompressedPublicKey, b: ECCUncompressedPublicKey): bool { | ||
return Utils.bytesCmp(a.data!, b.data!) < 0; | ||
} | ||
} | ||
export enum UserPresence { | ||
@@ -371,6 +420,6 @@ USER_PRESENCE_NONE = 0, | ||
export function k1Recover(sig: Signature, digest: Checksum256): PublicKey | null { | ||
export function k1Recover(sig: Signature, digest: Checksum256): ECCPublicKey | null { | ||
let rawSig = sig.pack(); | ||
let rawDigest = digest.pack(); | ||
let rawPub = new Array<u8>(34); | ||
let rawPub = new Array<u8>(65); | ||
let ret = env.recover_key(rawSig.dataStart, rawDigest.dataStart, rawDigest.length, rawPub.dataStart, rawPub.length); | ||
@@ -380,3 +429,3 @@ if (ret == -1) { | ||
} | ||
let pub = new PublicKey(); | ||
let pub = new ECCUncompressedPublicKey(); | ||
pub.unpack(rawPub); | ||
@@ -383,0 +432,0 @@ return pub; |
@@ -108,2 +108,3 @@ export { U128, U256, I128 } from "./bignum"; | ||
ECCPublicKey, | ||
ECCUncompressedPublicKey, | ||
UserPresence, | ||
@@ -110,0 +111,0 @@ WebAuthNPublicKey, |
{ | ||
"name": "as-chain", | ||
"version": "0.0.74", | ||
"version": "0.0.75", | ||
"description": "chain module for assemblyscript", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1576078
6704