Socket
Socket
Sign inDemoInstall

asmcrypto.js

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asmcrypto.js - npm Package Compare versions

Comparing version 0.19.0 to 0.19.1

417

asmcrypto.js.d.ts

@@ -1,17 +0,30 @@

declare class BigNumberInternal extends Number {
static ZERO: BigNumberInternal;
static ONE: BigNumberInternal;
constructor(num: Uint8Array|number);
declare class BigNumber {
static ZERO: BigNumber;
static ONE: BigNumber;
constructor(num: Uint8Array | number);
toString(radix?: number): string;
toBytes(): Uint8Array;
valueOf(): number;
clamp(b: number): BigNumberInternal;
slice(f: number,b: number): BigNumberInternal;
negate(): BigNumberInternal;
compare(that: BigNumberInternal): 0|1|-1;
add(that: BigNumberInternal): BigNumberInternal;
subtract(that: BigNumberInternal): BigNumberInternal;
multiply(that: BigNumberInternal): BigNumberInternal;
square(): BigNumberInternal;
divide(that: BigNumberInternal): BigNumberInternal;
clamp(b: number): BigNumber;
slice(f: number, b: number): BigNumber;
negate(): BigNumber;
compare(that: BigNumber): 0 | 1 | -1;
add(that: BigNumber): BigNumber;
subtract(that: BigNumber): BigNumber;
multiply(that: BigNumber): BigNumber;
square(): BigNumber;
divide(that: BigNumber): BigNumber;
}

@@ -22,30 +35,40 @@

result: Uint8Array;
constructor(key: Uint8Array, iv?: Uint8Array, padding?: boolean, heap?: Uint8Array, asm?: Uint8Array);
}
declare interface AES_reset<M> {
(key: Uint8Array, iv?: Uint8Array, padding?: boolean): M;
}
declare interface AES_Encrypt_finish<M> {
(data?: Uint8Array): M;
}
declare interface AES_Decrypt_finish<M> {
(data?: Uint8Array): M;
}
declare interface AES_Encrypt_process<M> {
(data: Uint8Array): M;
}
declare interface AES_Decrypt_process<M> {
(data: Uint8Array): M;
}
declare interface RSA_OAEP_Encrypt {
(data: Uint8Array, key: BigNumberInternal[], label?: Uint8Array): Uint8Array;
(data: Uint8Array, key: BigNumber[], label?: Uint8Array): Uint8Array;
}
declare interface RSA_OAEP_Decrypt {
(data: Uint8Array, key: BigNumberInternal[], label?: Uint8Array): Uint8Array;
(data: Uint8Array, key: BigNumber[], label?: Uint8Array): Uint8Array;
}
declare interface RSA_PSS_Sign {
(data: Uint8Array, key: BigNumberInternal[], slen?: number): Uint8Array;
(data: Uint8Array, key: BigNumber[], slen?: number): Uint8Array;
}
declare interface RSA_PSS_Verify {
(signature: Uint8Array, data: Uint8Array, key: BigNumberInternal[], slen?: number): boolean;
(signature: Uint8Array, data: Uint8Array, key: BigNumber[], slen?: number): boolean;
}

@@ -55,2 +78,3 @@

constructor(key: Uint8Array, heap?: Uint8Array);
reset: AES_reset<AES_ECB_Encrypt>;

@@ -63,2 +87,3 @@ process: AES_Encrypt_process<AES_ECB_Encrypt>;

constructor(key: Uint8Array, heap?: Uint8Array, asm?: Uint8Array);
encrypt: AES_Encrypt_finish<AES_ECB>;

@@ -70,2 +95,3 @@ decrypt: AES_Decrypt_finish<AES_ECB>;

constructor(key: Uint8Array, heap?: Uint8Array);
reset: AES_reset<AES_ECB_Decrypt>;

@@ -78,2 +104,3 @@ process: AES_Encrypt_process<AES_ECB_Decrypt>;

constructor(key: Uint8Array, iv: Uint8Array, padding?: boolean, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CBC_Encrypt>;

@@ -86,2 +113,3 @@ process: AES_Encrypt_process<AES_CBC_Encrypt>;

constructor(key: Uint8Array, iv: Uint8Array, padding?: boolean, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CBC_Decrypt>;

@@ -94,2 +122,3 @@ process: AES_Encrypt_process<AES_CBC_Decrypt>;

constructor(key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, dataLength?: number, tagSize?: number, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CCM_Encrypt>;

@@ -102,2 +131,3 @@ process: AES_Encrypt_process<AES_CCM_Encrypt>;

constructor(key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, dataLength?: number, tagSize?: number, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CCM_Decrypt>;

@@ -110,2 +140,3 @@ process: AES_Encrypt_process<AES_CCM_Decrypt>;

constructor(key: Uint8Array, iv?: Uint8Array, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CFB_Encrypt>;

@@ -118,2 +149,3 @@ process: AES_Encrypt_process<AES_CFB_Encrypt>;

constructor(key: Uint8Array, iv?: Uint8Array, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_CFB_Decrypt>;

@@ -126,2 +158,3 @@ process: AES_Encrypt_process<AES_CFB_Decrypt>;

constructor(key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_GCM_Encrypt>;

@@ -134,2 +167,3 @@ process: AES_Encrypt_process<AES_GCM_Encrypt>;

constructor(key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_GCM_Decrypt>;

@@ -142,2 +176,3 @@ process: AES_Encrypt_process<AES_GCM_Decrypt>;

constructor(key: Uint8Array, iv?: Uint8Array, heap?: Uint8Array, asm?: Uint8Array);
reset: AES_reset<AES_OFB>;

@@ -150,3 +185,5 @@ process: AES_Encrypt_process<AES_OFB>;

constructor(key: Uint8Array, nonce: Uint8Array, heap?: Uint8Array, asm?: Uint8Array);
reset(key: Uint8Array, nonce: Uint8Array, counter?: number, counterSize?: number): AES_CTR;
process: AES_Encrypt_process<AES_CTR>;

@@ -156,173 +193,211 @@ finish: AES_Encrypt_finish<AES_CTR>;

declare module 'asmcrypto.js/asmcrypto.all.js' {
export class BigNumber extends BigNumberInternal {
declare class AES_CBC {
static encrypt: (data: Uint8Array, key: Uint8Array, padding?: boolean, iv?: Uint8Array) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, padding?: boolean, iv?: Uint8Array) => Uint8Array;
}
}
declare class AES_CCM {
static encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
}
export const AES_ECB: {
encrypt: (data: Uint8Array, key: Uint8Array) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array) => Uint8Array;
Encrypt: typeof AES_ECB_Encrypt;
Decrypt: typeof AES_ECB_Decrypt;
};
export const AES_CBC: {
encrypt: (data: Uint8Array, key: Uint8Array, padding?: boolean, iv?: Uint8Array) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, padding?: boolean, iv?: Uint8Array) => Uint8Array;
Encrypt: typeof AES_CBC_Encrypt;
Decrypt: typeof AES_CBC_Decrypt;
};
export const AES_CCM: {
encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
Encrypt: typeof AES_CCM_Encrypt;
Decrypt: typeof AES_CCM_Decrypt;
};
export const AES_CFB: {
encrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
Encrypt: typeof AES_CFB_Encrypt;
Decrypt: typeof AES_CFB_Decrypt;
};
export const AES_CTR: {
encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array) => Uint8Array;
Encrypt: typeof AES_CTR;
Decrypt: typeof AES_CTR;
};
export const AES_OFB: {
encrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
Encrypt: typeof AES_OFB;
Decrypt: typeof AES_OFB;
};
export const AES_GCM: {
encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
Encrypt: typeof AES_GCM_Encrypt;
Decrypt: typeof AES_GCM_Decrypt;
};
export class SHA1 {
result: Uint8Array;
declare class AES_CFB {
static encrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
}
static bytes(data: Uint8Array): Uint8Array;
static hex(data: Uint8Array): string;
static base64(data: Uint8Array): string;
declare class AES_CTR {
static encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array) => Uint8Array;
}
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number});
reset(): SHA1;
process(data: Uint8Array): SHA1;
finish(): SHA1;
}
export class SHA256 {
result: Uint8Array;
declare class AES_OFB {
static encrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, iv?: Uint8Array) => Uint8Array;
}
static bytes(data: Uint8Array): Uint8Array;
static hex(data: Uint8Array): string;
static base64(data: Uint8Array): string;
declare class AES_GCM {
static encrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
static decrypt: (data: Uint8Array, key: Uint8Array, nonce: Uint8Array, adata?: Uint8Array, tagSize?: number) => Uint8Array;
}
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number});
reset(): SHA256;
process(data: Uint8Array): SHA256;
finish(): SHA256;
}
export class SHA512 {
result: Uint8Array;
declare class SHA1 {
result: Uint8Array;
static bytes(data: Uint8Array): Uint8Array;
static hex(data: Uint8Array): string;
static base64(data: Uint8Array): string;
static bytes(data: Uint8Array): Uint8Array;
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number});
reset(): SHA512;
process(data: Uint8Array): SHA512;
finish(): SHA512;
}
export class HMAC_SHA1 {
result: Uint8Array;
static hex(data: Uint8Array): string;
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array): string;
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA1});
reset(options: {password: Uint8Array}): HMAC_SHA1;
process(data: Uint8Array): HMAC_SHA1;
finish(): HMAC_SHA1;
}
export class HMAC_SHA256 {
result: Uint8Array;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number });
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
reset(): SHA1;
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA256});
reset(options: {password: Uint8Array}): HMAC_SHA256;
process(data: Uint8Array): HMAC_SHA256;
finish(): HMAC_SHA256;
}
export class HMAC_SHA512 {
result: Uint8Array;
process(data: Uint8Array): SHA1;
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
finish(): SHA1;
}
constructor(options: {asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA512});
reset(options: {password: Uint8Array}): HMAC_SHA512;
process(data: Uint8Array): HMAC_SHA512;
finish(): HMAC_SHA512;
}
export const PBKDF2_HMAC_SHA1: {
bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
};
export const PBKDF2_HMAC_SHA256: {
bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
};
export const PBKDF2_HMAC_SHA512: {
bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
};
export const RSA_OAEP_SHA1: {
encrypt: RSA_OAEP_Encrypt;
decrypt: RSA_OAEP_Decrypt;
};
export const RSA_OAEP_SHA256: {
encrypt: RSA_OAEP_Encrypt;
decrypt: RSA_OAEP_Decrypt;
};
export const RSA_OAEP_SHA512: {
encrypt: RSA_OAEP_Encrypt;
decrypt: RSA_OAEP_Decrypt;
};
export const RSA_PSS_SHA1: {
sign: RSA_PSS_Sign;
verify: RSA_PSS_Verify;
};
export const RSA_PSS_SHA256: {
sign: RSA_PSS_Sign;
verify: RSA_PSS_Verify;
};
export const RSA_PSS_SHA512: {
sign: RSA_PSS_Sign;
verify: RSA_PSS_Verify;
};
declare class SHA256 {
result: Uint8Array;
export function random(): number;
export namespace random {
export function seed(data: Uint8Array): boolean;
}
static bytes(data: Uint8Array): Uint8Array;
static hex(data: Uint8Array): string;
export function string_to_bytes(s: string): Uint8Array;
export function hex_to_bytes(s: string): Uint8Array;
export function base64_to_bytes(s: string): Uint8Array;
export function bytes_to_string(bytes: Uint8Array): string;
export function bytes_to_hex(bytes: Uint8Array): string;
export function bytes_to_base64(bytes: Uint8Array): string;
static base64(data: Uint8Array): string;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number });
reset(): SHA256;
process(data: Uint8Array): SHA256;
finish(): SHA256;
}
declare class SHA512 {
result: Uint8Array;
static bytes(data: Uint8Array): Uint8Array;
static hex(data: Uint8Array): string;
static base64(data: Uint8Array): string;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number });
reset(): SHA512;
process(data: Uint8Array): SHA512;
finish(): SHA512;
}
declare class HMAC_SHA1 {
result: Uint8Array;
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA1 });
reset(options: { password: Uint8Array }): HMAC_SHA1;
process(data: Uint8Array): HMAC_SHA1;
finish(): HMAC_SHA1;
}
declare class HMAC_SHA256 {
result: Uint8Array;
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA256 });
reset(options: { password: Uint8Array }): HMAC_SHA256;
process(data: Uint8Array): HMAC_SHA256;
finish(): HMAC_SHA256;
}
declare class HMAC_SHA512 {
result: Uint8Array;
static bytes(data: Uint8Array, password: Uint8Array): Uint8Array;
static hex(data: Uint8Array, password: Uint8Array): string;
static base64(data: Uint8Array, password: Uint8Array): string;
constructor(options?: { asm?: Uint8Array, heap?: Uint8Array, heapSize?: number, password?: Uint8Array, hash?: SHA512 });
reset(options: { password: Uint8Array }): HMAC_SHA512;
process(data: Uint8Array): HMAC_SHA512;
finish(): HMAC_SHA512;
}
declare class PBKDF2_HMAC_SHA1 {
static bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
}
declare class PBKDF2_HMAC_SHA256 {
static bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
}
declare class PBKDF2_HMAC_SHA512 {
static bytes(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static hex(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
static base64(password: Uint8Array, salt: Uint8Array, iterations?: number, dklen?: number): Uint8Array;
}
declare class RSA_OAEP_SHA1 {
static encrypt: RSA_OAEP_Encrypt;
static decrypt: RSA_OAEP_Decrypt;
}
declare class RSA_OAEP_SHA256 {
static encrypt: RSA_OAEP_Encrypt;
static decrypt: RSA_OAEP_Decrypt;
}
declare class RSA_OAEP_SHA512 {
static encrypt: RSA_OAEP_Encrypt;
static decrypt: RSA_OAEP_Decrypt;
}
declare class RSA_PSS_SHA1 {
static sign: RSA_PSS_Sign;
static verify: RSA_PSS_Verify;
}
declare class RSA_PSS_SHA256 {
static sign: RSA_PSS_Sign;
static verify: RSA_PSS_Verify;
}
declare class RSA_PSS_SHA512 {
static sign: RSA_PSS_Sign;
static verify: RSA_PSS_Verify;
}
declare function random(): number;
declare namespace random {
export function seed(data: Uint8Array): boolean;
}
declare function string_to_bytes(s: string): Uint8Array;
declare function hex_to_bytes(s: string): Uint8Array;
declare function base64_to_bytes(s: string): Uint8Array;
declare function bytes_to_string(bytes: Uint8Array): string;
declare function bytes_to_hex(bytes: Uint8Array): string;
declare function bytes_to_base64(bytes: Uint8Array): string;
{
"name": "asmcrypto.js",
"version": "0.19.0",
"version": "0.19.1",
"description": "Asm.js implementation of WebCrypto API",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/vibornoff/asmcrypto.js",

@@ -8,3 +8,3 @@ import { Random_getValues } from '../random/random';

export function is_big_number(a) {
return a instanceof BigNumber_constructor;
return a instanceof BigNumber;
}

@@ -37,6 +37,6 @@

export class BigNumber_constructor {
export class BigNumber {
/**
* @param {BigNumber_constructor|string|number|Uint8Array} num
* @return {BigNumber_constructor}
* @param {BigNumber|string|number|Uint8Array} num
* @return {BigNumber}
*/

@@ -183,3 +183,3 @@ constructor(num) {

* @param {number} b
* @return {BigNumber_constructor}
* @return {BigNumber}
*/

@@ -194,3 +194,3 @@ clamp(b) {

const clamped = new BigNumber_constructor();
const clamped = new BigNumber();
let n = (b + 31) >> 5;

@@ -211,3 +211,3 @@ let k = b % 32;

* @param {number} [b]
* @return {BigNumber_constructor}
* @return {BigNumber}
*/

@@ -228,3 +228,3 @@ slice(f, b) {

const sliced = new BigNumber_constructor();
const sliced = new BigNumber();
let n = f >> 5;

@@ -258,6 +258,6 @@ let m = (f + b + 31) >> 5;

/**
* @return {BigNumber_constructor}
* @return {BigNumber}
*/
negate() {
const negative = new BigNumber_constructor();
const negative = new BigNumber();

@@ -272,7 +272,7 @@ negative.limbs = this.limbs;

/**
* @param {BigNumber_constructor} that
* @param {BigNumber} that
* @return {number}
*/
compare(that) {
if (!is_big_number(that)) that = new BigNumber_constructor(that);
if (!is_big_number(that)) that = new BigNumber(that);

@@ -297,7 +297,7 @@ var alimbs = this.limbs,

/**
* @param {BigNumber_constructor} that
* @return {BigNumber_constructor}
* @param {BigNumber} that
* @return {BigNumber}
*/
add(that) {
if (!is_big_number(that)) that = new BigNumber_constructor(that);
if (!is_big_number(that)) that = new BigNumber(that);

@@ -320,3 +320,3 @@ if (!this.sign) return that;

rof,
result = new BigNumber_constructor();
result = new BigNumber();

@@ -360,7 +360,7 @@ rbitlen = (abitlen > bbitlen ? abitlen : bbitlen) + (asign * bsign > 0 ? 1 : 0);

/**
* @param {BigNumber_constructor} that
* @return {BigNumber_constructor}
* @param {BigNumber} that
* @return {BigNumber}
*/
subtract(that) {
if (!is_big_number(that)) that = new BigNumber_constructor(that);
if (!is_big_number(that)) that = new BigNumber(that);

@@ -371,3 +371,3 @@ return this.add(that.negate());

/**
* @return {BigNumber_constructor}
* @return {BigNumber}
*/

@@ -382,3 +382,3 @@ square() {

rlimbcnt,
result = new BigNumber_constructor();
result = new BigNumber();

@@ -407,7 +407,7 @@ rbitlen = abitlen << 1;

/**
* @param {BigNumber_constructor} that
* @return {{quotient: BigNumber_constructor, remainder: BigNumber_constructor}}
* @param {BigNumber} that
* @return {{quotient: BigNumber, remainder: BigNumber}}
*/
divide(that) {
if (!is_big_number(that)) that = new BigNumber_constructor(that);
if (!is_big_number(that)) that = new BigNumber(that);

@@ -440,3 +440,3 @@ var abitlen = this.bitLength,

if (qlimbcnt) {
quotient = new BigNumber_constructor();
quotient = new BigNumber();
quotient.limbs = new Uint32Array(_bigint_heap.subarray(pQ >> 2, (pQ >> 2) + qlimbcnt));

@@ -449,3 +449,3 @@ quotient.bitLength = abitlen < qlimbcnt << 5 ? abitlen : qlimbcnt << 5;

if (rlimbcnt) {
remainder = new BigNumber_constructor();
remainder = new BigNumber();
remainder.limbs = new Uint32Array(_bigint_heap.subarray(pA >> 2, (pA >> 2) + rlimbcnt));

@@ -463,7 +463,7 @@ remainder.bitLength = bbitlen < rlimbcnt << 5 ? bbitlen : rlimbcnt << 5;

/**
* @param {BigNumber_constructor} that
* @return {BigNumber_constructor}
* @param {BigNumber} that
* @return {BigNumber}
*/
multiply(that) {
if (!is_big_number(that)) that = new BigNumber_constructor(that);
if (!is_big_number(that)) that = new BigNumber(that);

@@ -480,3 +480,3 @@ if (!this.sign || !that.sign) return BigNumber_ZERO;

rlimbcnt,
result = new BigNumber_constructor();
result = new BigNumber();

@@ -512,3 +512,3 @@ rbitlen = abitlen + bbitlen;

_isMillerRabinProbablePrime(rounds) {
var t = new BigNumber_constructor(this),
var t = new BigNumber(this),
s = 0;

@@ -522,3 +522,3 @@ t.limbs[0] -= 1;

m1 = this.subtract(BigNumber_ONE),
a = new BigNumber_constructor(this),
a = new BigNumber(this),
l = this.limbs.length - 1;

@@ -601,4 +601,4 @@ while (a.limbs[l] === 0) l--;

export const BigNumber_ZERO = new BigNumber_constructor(0);
export const BigNumber_ONE = new BigNumber_constructor(1);
export const BigNumber_ZERO = new BigNumber(0);
export const BigNumber_ONE = new BigNumber(1);

@@ -629,8 +629,8 @@ /**

* @param {number} bitlen
* @param {function(p: BigNumber_constructor): number} filter
* @return {BigNumber_constructor}
* @param {function(p: BigNumber): number} filter
* @return {BigNumber}
*/
export function randomProbablePrime(bitlen, filter) {
let limbcnt = (bitlen + 31) >> 5;
const prime = new BigNumber_constructor({ sign: 1, bitLength: bitlen, limbs: limbcnt });
const prime = new BigNumber({ sign: 1, bitLength: bitlen, limbs: limbcnt });
const limbs = prime.limbs;

@@ -685,7 +685,7 @@

export class Modulus extends BigNumber_constructor {
export class Modulus extends BigNumber {
/**
* Modulus
*
* @param {BigNumber_constructor|string|number|Uint8Array} number
* @param {BigNumber|string|number|Uint8Array} number
*/

@@ -705,3 +705,3 @@ constructor(number) {

limbs[limbs.length - 1] = 1;
comodulus = new BigNumber_constructor();
comodulus = new BigNumber();
comodulus.sign = 1;

@@ -732,10 +732,10 @@ comodulus.bitLength = bitlen;

*
* @param {BigNumber_constructor} a
* @return {BigNumber_constructor}
* @param {BigNumber} a
* @return {BigNumber}
* @constructor
*/
reduce(a) {
if (!is_big_number(a)) a = new BigNumber_constructor(a);
if (!is_big_number(a)) a = new BigNumber(a);
if (a.bitLength <= 32 && this.bitLength <= 32) return new BigNumber_constructor(a.valueOf() % this.valueOf());
if (a.bitLength <= 32 && this.bitLength <= 32) return new BigNumber(a.valueOf() % this.valueOf());

@@ -750,4 +750,4 @@ if (a.compare(this) < 0) return a;

*
* @param {BigNumber_constructor} a
* @return {BigNumber_constructor}
* @param {BigNumber} a
* @return {BigNumber}
* @constructor

@@ -769,11 +769,11 @@ */

*
* @param {BigNumber_constructor} g
* @param {BigNumber_constructor} e
* @return {BigNumber_constructor}
* @param {BigNumber} g
* @param {BigNumber} e
* @return {BigNumber}
* @constructor
*/
power(g, e) {
if (!is_big_number(g)) g = new BigNumber_constructor(g);
if (!is_big_number(g)) g = new BigNumber(g);
if (!is_big_number(e)) e = new BigNumber_constructor(e);
if (!is_big_number(e)) e = new BigNumber(e);

@@ -845,5 +845,5 @@ // count exponent set bits

/**
* @param {BigNumber_constructor} a
* @param {BigNumber_constructor} n
* @return {BigNumber_constructor}
* @param {BigNumber} a
* @param {BigNumber} n
* @return {BigNumber}
* @private

@@ -871,3 +871,3 @@ */

const result = new BigNumber_constructor();
const result = new BigNumber();
result.limbs = new Uint32Array(_bigint_heap.subarray(pR >> 2, (pR >> 2) + nlimbcnt));

@@ -874,0 +874,0 @@ result.bitLength = n.bitLength;

@@ -1,5 +0,4 @@

import { BigNumber_constructor, BigNumber_ONE, BigNumber_ZERO, Modulus } from './bignum';
import { BigNumber, BigNumber_ONE, BigNumber_ZERO, Modulus } from './bignum';
import { BigNumber_extGCD } from './extgcd';
export var BigNumber = BigNumber_constructor;
BigNumber.ZERO = BigNumber_ZERO;

@@ -10,2 +9,2 @@ BigNumber.ONE = BigNumber_ONE;

export { Modulus };
export { BigNumber, Modulus };

@@ -1,2 +0,2 @@

import { BigNumber_constructor, BigNumber_ONE, BigNumber_ZERO, is_big_number } from './bignum';
import { BigNumber, BigNumber_ONE, BigNumber_ZERO, is_big_number } from './bignum';

@@ -60,9 +60,9 @@ /**

* @param b
* @return {{gcd: BigNumber_constructor, x: BigNumber_constructor, y: BigNumber_constructor}}
* @return {{gcd: BigNumber, x: BigNumber, y: BigNumber}}
* @constructor
*/
export function BigNumber_extGCD(a, b) {
if (!is_big_number(a)) a = new BigNumber_constructor(a);
if (!is_big_number(a)) a = new BigNumber(a);
if (!is_big_number(b)) b = new BigNumber_constructor(b);
if (!is_big_number(b)) b = new BigNumber(b);

@@ -69,0 +69,0 @@ var sa = a.sign,

@@ -10,3 +10,3 @@ /**

import { BigNumber_extGCD } from '../bignum/extgcd';
import { BigNumber_constructor, is_big_number, Modulus } from '../bignum/bignum';
import { BigNumber, is_big_number, Modulus } from '../bignum/bignum';
import { is_buffer, is_bytes, is_number, is_string, string_to_bytes } from '../utils';

@@ -26,3 +26,3 @@ import { IllegalArgumentError } from '../errors';

if (is_bytes(e) || is_number(e) || is_big_number(e)) {
e = new BigNumber_constructor(e);
e = new BigNumber(e);
} else {

@@ -37,3 +37,3 @@ throw new TypeError('unexpected exponent type');

p = randomProbablePrime(bitlen >> 1, function(p) {
p1 = new BigNumber_constructor(p);
p1 = new BigNumber(p);
p1.limbs[0] -= 1;

@@ -46,3 +46,3 @@ return BigNumber_extGCD(p1, e).gcd.valueOf() == 1;

if (!(m.limbs[((bitlen + 31) >> 5) - 1] >>> ((bitlen - 1) & 31))) return false;
q1 = new BigNumber_constructor(q);
q1 = new BigNumber(q);
q1.limbs[0] -= 1;

@@ -49,0 +49,0 @@ return BigNumber_extGCD(q1, e).gcd.valueOf() == 1;

@@ -1,2 +0,2 @@

import { BigNumber_constructor, is_big_number, Modulus } from '../bignum/bignum';
import { BigNumber, is_big_number, Modulus } from '../bignum/bignum';
import { is_buffer, is_bytes, is_string, string_to_bytes } from '../utils';

@@ -27,5 +27,5 @@ import { IllegalStateError } from '../errors';

k[0] = new Modulus(key[0]);
k[1] = new BigNumber_constructor(key[1]);
k[1] = new BigNumber(key[1]);
if (l > 2) {
k[2] = new BigNumber_constructor(key[2]);
k[2] = new BigNumber(key[2]);
}

@@ -35,5 +35,5 @@ if (l > 3) {

k[4] = new Modulus(key[4]);
k[5] = new BigNumber_constructor(key[5]);
k[6] = new BigNumber_constructor(key[6]);
k[7] = new BigNumber_constructor(key[7]);
k[5] = new BigNumber(key[5]);
k[6] = new BigNumber(key[6]);
k[7] = new BigNumber(key[7]);
}

@@ -59,3 +59,3 @@

if (is_bytes(data)) {
msg = new BigNumber_constructor(data);
msg = new BigNumber(data);
} else if (is_big_number(data)) {

@@ -97,3 +97,3 @@ msg = data;

if (is_bytes(data)) {
msg = new BigNumber_constructor(data);
msg = new BigNumber(data);
} else if (is_big_number(data)) {

@@ -100,0 +100,0 @@ msg = data;

@@ -1,2 +0,2 @@

/*! asmCrypto v0.19.0, (c) 2018 asmCrypto.js, opensource.org/licenses/MIT */
/*! asmCrypto v0.19.1, (c) 2018 asmCrypto.js, opensource.org/licenses/MIT */
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc