This commit is contained in:
Florian Dold 2017-05-28 22:31:54 +02:00
parent e7fa87bcc0
commit a418875877
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
6 changed files with 254 additions and 7 deletions

View File

@ -17,8 +17,6 @@
/** /**
* General helper React components. * General helper React components.
*
* @author Florian Dold
*/ */
@ -27,6 +25,10 @@
*/ */
import * as React from "react"; import * as React from "react";
/**
* Wrapper around state that will cause updates to the
* containing component.
*/
export interface StateHolder<T> { export interface StateHolder<T> {
(): T; (): T;
(newState: T): void; (newState: T): void;

View File

@ -84,6 +84,10 @@ interface WorkItem {
*/ */
const NUM_PRIO = 5; const NUM_PRIO = 5;
/**
* Crypto API that interfaces manages a background crypto thread
* for the execution of expensive operations.
*/
export class CryptoApi { export class CryptoApi {
private nextRpcId: number = 1; private nextRpcId: number = 1;
private workers: WorkerState[]; private workers: WorkerState[];

View File

@ -592,6 +592,9 @@ export class EddsaPrivateKey extends PackedArenaObject {
} }
/**
* Low-level handle to an EdDSA private key.
*/
export class EcdsaPrivateKey extends PackedArenaObject { export class EcdsaPrivateKey extends PackedArenaObject {
static create(a?: Arena): EcdsaPrivateKey { static create(a?: Arena): EcdsaPrivateKey {
const obj = new EcdsaPrivateKey(a); const obj = new EcdsaPrivateKey(a);
@ -615,6 +618,9 @@ export class EcdsaPrivateKey extends PackedArenaObject {
} }
/**
* Low-level handle to an ECDHE private key.
*/
export class EcdhePrivateKey extends PackedArenaObject { export class EcdhePrivateKey extends PackedArenaObject {
static create(a?: Arena): EcdhePrivateKey { static create(a?: Arena): EcdhePrivateKey {
const obj = new EcdhePrivateKey(a); const obj = new EcdhePrivateKey(a);
@ -646,6 +652,9 @@ interface Ctor<T> {
} }
/**
* Low-level handle to an EdDSA public key.
*/
export class EddsaPublicKey extends PackedArenaObject { export class EddsaPublicKey extends PackedArenaObject {
size() { size() {
return 32; return 32;
@ -656,6 +665,9 @@ export class EddsaPublicKey extends PackedArenaObject {
} }
} }
/**
* Low-level handle to an ECDSA public key.
*/
export class EcdsaPublicKey extends PackedArenaObject { export class EcdsaPublicKey extends PackedArenaObject {
size() { size() {
return 32; return 32;
@ -667,6 +679,9 @@ export class EcdsaPublicKey extends PackedArenaObject {
} }
/**
* Low-level handle to an ECDHE public key.
*/
export class EcdhePublicKey extends PackedArenaObject { export class EcdhePublicKey extends PackedArenaObject {
size() { size() {
return 32; return 32;
@ -677,6 +692,10 @@ export class EcdhePublicKey extends PackedArenaObject {
} }
} }
/**
* Low-level handle to a blinding key secret.
*/
export class RsaBlindingKeySecret extends PackedArenaObject { export class RsaBlindingKeySecret extends PackedArenaObject {
size() { size() {
return 32; return 32;
@ -698,6 +717,9 @@ export class RsaBlindingKeySecret extends PackedArenaObject {
} }
/**
* Low-level handle to a hash code.
*/
export class HashCode extends PackedArenaObject { export class HashCode extends PackedArenaObject {
size() { size() {
return 64; return 64;
@ -714,6 +736,9 @@ export class HashCode extends PackedArenaObject {
} }
/**
* Low-level handle to a byte array.
*/
export class ByteArray extends PackedArenaObject { export class ByteArray extends PackedArenaObject {
private allocatedSize: number; private allocatedSize: number;
@ -856,16 +881,36 @@ abstract class SignatureStruct {
} }
// It's redundant, but more type safe. /**
* Arguments to constructor of [[WithdrawRequestPS]].
*/
export interface WithdrawRequestPS_Args { export interface WithdrawRequestPS_Args {
/**
* Reserve public key.
*/
reserve_pub: EddsaPublicKey; reserve_pub: EddsaPublicKey;
/**
* Amount with fee.
*/
amount_with_fee: AmountNbo; amount_with_fee: AmountNbo;
/**
* Withdraw fee.
*/
withdraw_fee: AmountNbo; withdraw_fee: AmountNbo;
/**
* Hash of denomination public key.
*/
h_denomination_pub: HashCode; h_denomination_pub: HashCode;
/**
* Hash of coin envelope.
*/
h_coin_envelope: HashCode; h_coin_envelope: HashCode;
} }
/**
* Low-level handle to a WithdrawRequest signature structure.
*/
export class WithdrawRequestPS extends SignatureStruct { export class WithdrawRequestPS extends SignatureStruct {
constructor(w: WithdrawRequestPS_Args) { constructor(w: WithdrawRequestPS_Args) {
super(w); super(w);
@ -887,6 +932,9 @@ export class WithdrawRequestPS extends SignatureStruct {
} }
/**
* Arguments for constructor or [[PaybackRequestPS]].
*/
export interface PaybackRequestPS_args { export interface PaybackRequestPS_args {
coin_pub: EddsaPublicKey; coin_pub: EddsaPublicKey;
h_denom_pub: HashCode; h_denom_pub: HashCode;
@ -894,6 +942,9 @@ export interface PaybackRequestPS_args {
} }
/**
* Low-level handle to a PaybackRequest signature structure.
*/
export class PaybackRequestPS extends SignatureStruct { export class PaybackRequestPS extends SignatureStruct {
constructor(w: PaybackRequestPS_args) { constructor(w: PaybackRequestPS_args) {
super(w); super(w);
@ -913,6 +964,9 @@ export class PaybackRequestPS extends SignatureStruct {
} }
/**
* Arguments for constructor of [[RefreshMeltCoinAffirmationPS]].
*/
interface RefreshMeltCoinAffirmationPS_Args { interface RefreshMeltCoinAffirmationPS_Args {
session_hash: HashCode; session_hash: HashCode;
amount_with_fee: AmountNbo; amount_with_fee: AmountNbo;
@ -920,8 +974,10 @@ interface RefreshMeltCoinAffirmationPS_Args {
coin_pub: EddsaPublicKey; coin_pub: EddsaPublicKey;
} }
/**
* Low-level handle to a RefreshMeltCoinAffirmationPS signature structure.
*/
export class RefreshMeltCoinAffirmationPS extends SignatureStruct { export class RefreshMeltCoinAffirmationPS extends SignatureStruct {
constructor(w: RefreshMeltCoinAffirmationPS_Args) { constructor(w: RefreshMeltCoinAffirmationPS_Args) {
super(w); super(w);
} }
@ -941,14 +997,36 @@ export class RefreshMeltCoinAffirmationPS extends SignatureStruct {
} }
/**
* Arguments for constructor of [[MasterWireFeePS]].
*/
interface MasterWireFeePS_Args { interface MasterWireFeePS_Args {
/**
* Hash of wire method.
*/
h_wire_method: HashCode; h_wire_method: HashCode;
/**
* Start date.
*/
start_date: AbsoluteTimeNbo; start_date: AbsoluteTimeNbo;
/**
* End date.
*/
end_date: AbsoluteTimeNbo; end_date: AbsoluteTimeNbo;
/**
* Wire fee.
*/
wire_fee: AmountNbo; wire_fee: AmountNbo;
/**
* Closing fee.
*/
closing_fee: AmountNbo; closing_fee: AmountNbo;
} }
/**
* Low-level handle to a structure being signed over.
*/
export class MasterWireFeePS extends SignatureStruct { export class MasterWireFeePS extends SignatureStruct {
constructor(w: MasterWireFeePS_Args) { constructor(w: MasterWireFeePS_Args) {
super(w); super(w);
@ -970,6 +1048,9 @@ export class MasterWireFeePS extends SignatureStruct {
} }
/**
* Low-level handle to an absolute time in network byte order (NBO).
*/
export class AbsoluteTimeNbo extends PackedArenaObject { export class AbsoluteTimeNbo extends PackedArenaObject {
static fromTalerString(s: string): AbsoluteTimeNbo { static fromTalerString(s: string): AbsoluteTimeNbo {
const x = new AbsoluteTimeNbo(); const x = new AbsoluteTimeNbo();
@ -1017,6 +1098,9 @@ function set32(p: number, n: number) {
} }
/**
* Low-level handle to an unsigned 64-bit value.
*/
export class UInt64 extends PackedArenaObject { export class UInt64 extends PackedArenaObject {
static fromNumber(n: number): UInt64 { static fromNumber(n: number): UInt64 {
const x = new UInt64(); const x = new UInt64();
@ -1031,8 +1115,11 @@ export class UInt64 extends PackedArenaObject {
} }
/**
* Low-level handle to an unsigned 32-bit value.
*/
export class UInt32 extends PackedArenaObject { export class UInt32 extends PackedArenaObject {
static fromNumber(n: number): UInt64 { static fromNumber(n: number): UInt32 {
const x = new UInt32(); const x = new UInt32();
x.alloc(); x.alloc();
set32(x.nativePtr, n); set32(x.nativePtr, n);
@ -1045,19 +1132,48 @@ export class UInt32 extends PackedArenaObject {
} }
// It's redundant, but more type safe. /**
* Argument to the constructor of [[DepositRequestPS]].
*/
export interface DepositRequestPS_Args { export interface DepositRequestPS_Args {
/**
* Contract hash.
*/
h_contract: HashCode; h_contract: HashCode;
/**
* Wire info hash.
*/
h_wire: HashCode; h_wire: HashCode;
/**
* Timestamp.
*/
timestamp: AbsoluteTimeNbo; timestamp: AbsoluteTimeNbo;
/**
* Refund deadline.
*/
refund_deadline: AbsoluteTimeNbo; refund_deadline: AbsoluteTimeNbo;
/**
* Amount with fee.
*/
amount_with_fee: AmountNbo; amount_with_fee: AmountNbo;
/**
* Deposit fee.
*/
deposit_fee: AmountNbo; deposit_fee: AmountNbo;
/**
* Merchant public key.
*/
merchant: EddsaPublicKey; merchant: EddsaPublicKey;
/**
* Public key of the coin being deposited.
*/
coin_pub: EddsaPublicKey; coin_pub: EddsaPublicKey;
} }
/**
* Low-level handle to a struct being signed over.
*/
export class DepositRequestPS extends SignatureStruct { export class DepositRequestPS extends SignatureStruct {
constructor(w: DepositRequestPS_Args) { constructor(w: DepositRequestPS_Args) {
super(w); super(w);
@ -1081,6 +1197,9 @@ export class DepositRequestPS extends SignatureStruct {
} }
} }
/**
* Arguments for constuctor of [[DenominationKeyValidityPS]].
*/
export interface DenominationKeyValidityPS_args { export interface DenominationKeyValidityPS_args {
master: EddsaPublicKey; master: EddsaPublicKey;
start: AbsoluteTimeNbo; start: AbsoluteTimeNbo;
@ -1095,6 +1214,10 @@ export interface DenominationKeyValidityPS_args {
denom_hash: HashCode; denom_hash: HashCode;
} }
/**
* Low-level handle to a structure being signed over.
*/
export class DenominationKeyValidityPS extends SignatureStruct { export class DenominationKeyValidityPS extends SignatureStruct {
constructor(w: DenominationKeyValidityPS_args) { constructor(w: DenominationKeyValidityPS_args) {
super(w); super(w);
@ -1121,10 +1244,20 @@ export class DenominationKeyValidityPS extends SignatureStruct {
} }
} }
/**
* Arguments to constructor of [[PaymentSignaturePS]].
*/
export interface PaymentSignaturePS_args { export interface PaymentSignaturePS_args {
/**
* Contract hash.
*/
contract_hash: HashCode; contract_hash: HashCode;
} }
/**
* Low-level handle to a structure being signed over.
*/
export class PaymentSignaturePS extends SignatureStruct { export class PaymentSignaturePS extends SignatureStruct {
constructor(w: PaymentSignaturePS_args) { constructor(w: PaymentSignaturePS_args) {
super(w); super(w);
@ -1142,6 +1275,9 @@ export class PaymentSignaturePS extends SignatureStruct {
} }
/**
* Low-level handle to an RsaPublicKey.
*/
export class RsaPublicKey extends MallocArenaObject { export class RsaPublicKey extends MallocArenaObject {
static fromCrock(s: string): RsaPublicKey { static fromCrock(s: string): RsaPublicKey {
return fromCrockDecoded(s, this, emscAlloc.rsa_public_key_decode); return fromCrockDecoded(s, this, emscAlloc.rsa_public_key_decode);
@ -1162,6 +1298,9 @@ export class RsaPublicKey extends MallocArenaObject {
} }
/**
* Low-level handle to an EddsaSignature.
*/
export class EddsaSignature extends PackedArenaObject { export class EddsaSignature extends PackedArenaObject {
size() { size() {
return 64; return 64;
@ -1172,6 +1311,9 @@ export class EddsaSignature extends PackedArenaObject {
} }
/**
* Low-level handle to an RsaSignature.
*/
export class RsaSignature extends MallocArenaObject { export class RsaSignature extends MallocArenaObject {
static fromCrock(s: string, a?: Arena) { static fromCrock(s: string, a?: Arena) {
return fromCrockDecoded(s, this, emscAlloc.rsa_signature_decode); return fromCrockDecoded(s, this, emscAlloc.rsa_signature_decode);
@ -1263,8 +1405,17 @@ export function rsaUnblind(sig: RsaSignature,
type TransferSecretP = HashCode; type TransferSecretP = HashCode;
/**
* A fresh coin generated from a sed.
*/
export interface FreshCoin { export interface FreshCoin {
/**
* The coin's private key.
*/
priv: EddsaPrivateKey; priv: EddsaPrivateKey;
/**
* The blinding key to use for withdrawal.
*/
blindingKey: RsaBlindingKeySecret; blindingKey: RsaBlindingKeySecret;
} }

View File

@ -17,6 +17,10 @@
declare function getLib(): EmscLib; declare function getLib(): EmscLib;
/**
* Signature of the function that retrieves emscripten
* function implementations.
*/
export interface EmscFunGen { export interface EmscFunGen {
(name: string, (name: string,
ret: string, ret: string,

View File

@ -509,6 +509,9 @@ class IterQueryStream<T> extends QueryStreamBase<T> {
} }
/**
* Root wrapper around an IndexedDB for queries with a fluent interface.
*/
export class QueryRoot implements PromiseLike<void> { export class QueryRoot implements PromiseLike<void> {
private work: Array<((t: IDBTransaction) => void)> = []; private work: Array<((t: IDBTransaction) => void)> = [];
private stores = new Set(); private stores = new Set();

View File

@ -127,25 +127,66 @@ export interface ReserveRecord {
hasPayback: boolean; hasPayback: boolean;
} }
/**
* Auditor record as stored with currencies in the exchange database.
*/
export interface AuditorRecord { export interface AuditorRecord {
/**
* Base url of the auditor.
*/
baseUrl: string; baseUrl: string;
/**
* Public signing key of the auditor.
*/
auditorPub: string; auditorPub: string;
/**
* Time when the auditing expires.
*/
expirationStamp: number; expirationStamp: number;
} }
/**
* Exchange for currencies as stored in the wallet's currency
* information database.
*/
export interface ExchangeForCurrencyRecord { export interface ExchangeForCurrencyRecord {
/** /**
* Priority for automatic selection when withdrawing. * Priority for automatic selection when withdrawing.
* FIXME: unused?
*/ */
priority: number; priority: number;
/**
* FIXME: unused?
*/
pinnedPub?: string; pinnedPub?: string;
/**
* Base URL of the exchange.
*/
baseUrl: string; baseUrl: string;
} }
/**
* Information about a currency as displayed in the wallet's database.
*/
export interface CurrencyRecord { export interface CurrencyRecord {
/**
* Name of the currency.
*/
name: string; name: string;
/**
* Number of fractional digits to show when rendering the currency.
*/
fractionalDigits: number; fractionalDigits: number;
/**
* Auditors that the wallet trusts for this currency.
*/
auditors: AuditorRecord[]; auditors: AuditorRecord[];
/**
* Exchanges that the wallet trusts for this currency.
*/
exchanges: ExchangeForCurrencyRecord[]; exchanges: ExchangeForCurrencyRecord[];
} }
@ -431,19 +472,61 @@ export interface ExchangeRecord {
lastUpdateTime: number; lastUpdateTime: number;
} }
/**
* Wire info, sent to the bank when creating a reserve. Fee information will
* be filtered out. Only methods that the bank also supports should be sent.
*/
export interface WireInfo { export interface WireInfo {
/**
* Mapping from wire method type to the exchange's wire info,
* excluding fees.
*/
[type: string]: any; [type: string]: any;
} }
/**
* Information about what will happen when creating a reserve.
*
* Sent to the wallet frontend to be rendered and shown to the user.
*/
export interface ReserveCreationInfo { export interface ReserveCreationInfo {
/**
* Exchange that the reserve will be created at.
*/
exchangeInfo: ExchangeRecord; exchangeInfo: ExchangeRecord;
/**
* Filtered wire info to send to the bank.
*/
wireInfo: WireInfo; wireInfo: WireInfo;
/**
* Selected denominations for withdraw.
*/
selectedDenoms: DenominationRecord[]; selectedDenoms: DenominationRecord[];
/**
* Fees for withdraw.
*/
withdrawFee: AmountJson; withdrawFee: AmountJson;
/**
* Remaining balance that is too small to be withdrawn.
*/
overhead: AmountJson; overhead: AmountJson;
/**
* Wire fees from the exchange.
*/
wireFees: ExchangeWireFeesRecord; wireFees: ExchangeWireFeesRecord;
/**
* Does the wallet know about an auditor for
* the exchange that the reserve.
*/
isAudited: boolean; isAudited: boolean;
/**
* The exchange is trusted directly.
*/
isTrusted: boolean; isTrusted: boolean;
/**
* The earliest deposit expiration of the selected coins.
*/
earliestDepositExpiration: number; earliestDepositExpiration: number;
} }
@ -790,7 +873,7 @@ export interface WalletBalance {
* Mapping from currency name to defailed balance info. * Mapping from currency name to defailed balance info.
*/ */
[currency: string]: WalletBalanceEntry; [currency: string]: WalletBalanceEntry;
}; }
/** /**