;
+ isValid(): boolean;
+ toBits(): BitArray;
+ }
+
+ interface SjclEllipticalPointStatic {
+ new (curve: SjclEllipticalCurve, x?: BigNumber, y?: BigNumber): SjclEllipticalPoint;
+ }
+
+ interface SjclPointJacobian {
+ add(T: SjclEllipticalPoint): SjclPointJacobian;
+ doubl(): SjclPointJacobian;
+ toAffine(): SjclEllipticalPoint;
+ mult(k: BigNumber, affine: SjclEllipticalPoint): SjclPointJacobian;
+ mult2(k1: BigNumber, affine: SjclEllipticalPoint, k2: BigNumber, affine2: SjclEllipticalPoint): SjclPointJacobian;
+ isValid(): boolean;
+ }
+
+ interface SjclPointJacobianStatic {
+ new (curve: SjclEllipticalCurve, x?: BigNumber, y?: BigNumber, z?: BigNumber):SjclPointJacobian;
+ }
+
+ interface SjclEllipticalCurve {
+ fromBits(bits: BitArray): SjclEllipticalPoint;
+ }
+
+ interface SjclEllipticalCurveStatic {
+ new (Field: BigNumber, r: BigNumber, a: BigNumber, b: BigNumber, x: BigNumber, y: BigNumber): SjclEllipticalCurve;
+ }
+
+ interface SjclKeyPair {
+ pub: P;
+ sec: S;
+ }
+
+ interface SjclKeysGenerator
{
+ (curve: SjclEllipticalCurve, paranoia: number, sec?: BigNumber): SjclKeyPair
;
+ (curve: number, paranoia: number, sec?: BigNumber): SjclKeyPair
;
+ }
+
+ interface SjclECCPublicKeyData {
+ x: BitArray;
+ y: BitArray;
+ }
+
+ class SjclECCPublicKey {
+ get(): SjclECCPublicKeyData;
+ }
+
+ class SjclECCSecretKey {
+ get(): BitArray;
+ }
+
+ interface SjclECCPublicKeyFactory {
+ new (curve: SjclEllipticalCurve, point: SjclEllipticalPoint): T;
+ new (curve: SjclEllipticalCurve, point: BitArray): T;
+ }
+
+ interface SjclECCSecretKeyFactory {
+ new (curve: SjclEllipticalCurve, exponent: BigNumber): T;
+ }
+
+ interface SjclECCBasic {
+ publicKey: SjclECCPublicKeyFactory;
+ secretKey: SjclECCSecretKeyFactory;
+ generateKeys(cn: string): SjclKeysGenerator;
+ }
+
+ class SjclElGamalPublicKey extends SjclECCPublicKey {
+ kem(paranoia: number): {
+ key: BitArray;
+ tag: BitArray;
+ };
+ }
+
+ class SjclElGamalSecretKey extends SjclECCSecretKey {
+ unkem(tag: BitArray): BitArray;
+ dh(pk: SjclECCPublicKey): BitArray;
+ }
+
+ interface SjclElGamal {
+ publicKey: SjclECCPublicKeyFactory;
+ secretKey: SjclECCSecretKeyFactory;
+ generateKeys: SjclKeysGenerator;
+ }
+
+ class SjclEcdsaPublicKey extends SjclECCPublicKey {
+ verify(hash: BitArray, rs: BitArray, fakeLegacyVersion: boolean): boolean;
+ }
+
+ class SjclEcdsaSecretKey extends SjclECCSecretKey {
+ sign(hash: BitArray, paranoia: number, fakeLegacyVersion: boolean, fixedKForTesting?: BigNumber): BitArray;
+ }
+
+ interface SjclEcdsa {
+ publicKey: SjclECCPublicKeyFactory;
+ secretKey: SjclECCSecretKeyFactory;
+ generateKeys: SjclKeysGenerator;
+ }
+
+ // ________________________________________________________________________
+
+ interface SjclRandom {
+ randomWords(nwords: number, paranoia?: number): BitArray;
+ setDefaultParanoia(paranoia: number, allowZeroParanoia: string): void;
+ addEntropy(data: number, estimatedEntropy: number, source: string): void;
+ addEntropy(data: number[], estimatedEntropy: number, source: string): void;
+ addEntropy(data: string, estimatedEntropy: number, source: string): void;
+ isReady(paranoia?: number): boolean;
+ getProgress(paranoia?: number): number;
+ startCollectors(): void;
+ stopCollectors(): void;
+ addEventListener(name: string, cb: Function): void;
+ removeEventListener(name: string, cb: Function): void;
+ }
+
+ interface SjclRandomStatic {
+ new (defaultParanoia: number): SjclRandom;
+ }
+
+ // ________________________________________________________________________
+
+ interface SjclKeyExchange {
+ srp: SecureRemotePassword;
+ }
+
+ interface SjclSRPGroup {
+ N: BigNumber;
+ g: BigNumber;
+ }
+
+ interface SecureRemotePassword {
+ makeVerifier(username: string, password: string, salt: BitArray, group: SjclSRPGroup): BitArray;
+ makeX(username: string, password: string, salt: BitArray): BitArray;
+ knownGroup(i: string): SjclSRPGroup;
+ knownGroup(i: number): SjclSRPGroup;
+ }
+
+ // ________________________________________________________________________
+
+ interface SjclCipherParams {
+ v?: number;
+ iter?: number;
+ ks?: number;
+ ts?: number;
+ mode?: string;
+ adata?: string;
+ cipher?: string;
+ }
+
+ interface SjclCipherEncryptParams extends SjclCipherParams {
+ salt: BitArray;
+ iv: BitArray;
+ }
+
+ interface SjclCipherDecryptParams extends SjclCipherParams {
+ salt?: BitArray;
+ iv?: BitArray;
+ }
+
+ interface SjclCipherEncrypted extends SjclCipherEncryptParams {
+ kemtag?: BitArray;
+ ct: BitArray;
+ }
+
+ interface SjclCipherDecrypted extends SjclCipherEncrypted {
+ key: BitArray;
+ }
+
+ interface SjclConveninceEncryptor {
+ (password: string, plaintext: string, params?: SjclCipherEncryptParams, rp?: SjclCipherEncrypted): SjclCipherEncrypted;
+ (password: BitArray, plaintext: string, params?: SjclCipherEncryptParams, rp?: SjclCipherEncrypted): SjclCipherEncrypted;
+ (password: SjclElGamalPublicKey, plaintext: string, params?: SjclCipherEncryptParams, rp?: SjclCipherEncrypted): SjclCipherEncrypted;
+ }
+
+ interface SjclConveninceDecryptor {
+ (password: string, ciphertext: SjclCipherEncrypted, params?: SjclCipherDecryptParams, rp?: SjclCipherDecrypted): string;
+ (password: BitArray, ciphertext: SjclCipherEncrypted, params?: SjclCipherDecryptParams, rp?: SjclCipherDecrypted): string;
+ (password: SjclElGamalSecretKey, ciphertext: SjclCipherEncrypted, params?: SjclCipherDecryptParams, rp?: SjclCipherDecrypted): string;
+ }
+
+ interface SjclJson {
+ encrypt: SjclConveninceEncryptor;
+ decrypt: SjclConveninceDecryptor;
+ encode(obj: Object): string;
+ decode(obj: string): Object;
+ }
+
+ // ________________________________________________________________________
+
+ module TypeHelpers {
+ interface One {
+ (value: T): BigNumber;
+ }
+
+ interface BigNumberBinaryOperator extends One, One, One {
+ }
+
+ interface Two {
+ (x: T1, N: T2): BigNumber;
+ }
+
+ interface Bind1 extends Two, Two, Two {
+ }
+
+ interface BigNumberTrinaryOperator extends Bind1, Bind1, Bind1 {
+ }
+ }
+}