Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multisig credentials #110

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { SignifyClient } from "./clienting"
import { Tier} from "../core/salter"
import {Algos} from '../core/manager'
import {incept, interact, reply, rotate} from "../core/eventing"
import {b,Serials, Versionage} from "../core/core"
import {Tholder} from "../core/tholder"
import {MtrDex} from "../core/matter"
import {Serder} from "../core/serder"
import {parseRangeHeaders} from "../core/httping"
import { Tier } from "../core/salter"
import { Algos } from '../core/manager'
import { incept, interact, reply, rotate } from "../core/eventing"
import { b, Serials, Versionage } from "../core/core"
import { Tholder } from "../core/tholder"
import { MtrDex } from "../core/matter"
import { Serder } from "../core/serder"
import { parseRangeHeaders } from "../core/httping"

/** Arguments required to create an identfier */
export interface CreateIdentiferArgs {
Expand Down Expand Up @@ -67,17 +67,17 @@ export class Identifier {
* @param {number} [end=24] End index of list of notifications, defaults to 24
* @returns {Promise<any>} A promise to the list of managed identifiers
*/
async list(start:number=0, end:number=24): Promise<any> {
async list(start: number = 0, end: number = 24): Promise<any> {
let extraHeaders = new Headers()
extraHeaders.append('Range', `aids=${start}-${end}`)

let path = `/identifiers`
let data = null
let method = 'GET'
let res = await this.client.fetch(path, method, data, extraHeaders)

let cr = res.headers.get('content-range')
let range = parseRangeHeaders(cr,"aids")
let range = parseRangeHeaders(cr, "aids")
let aids = await res.json()

return {
Expand Down Expand Up @@ -109,7 +109,7 @@ export class Identifier {
* @param {CreateIdentiferArgs} [kargs] Optional parameters to create the identifier
* @returns {EventResult} The inception result
*/
create(name: string, kargs:CreateIdentiferArgs={}): EventResult {
create(name: string, kargs: CreateIdentiferArgs = {}): EventResult {

const algo = kargs.algo == undefined ? Algos.salty : kargs.algo

Expand Down Expand Up @@ -163,7 +163,7 @@ export class Identifier {
let keeper = this.client.manager!.new(algo, this.client.pidx, xargs)
let [keys, ndigs] = keeper!.incept(transferable)
wits = wits !== undefined ? wits : []
let serder: Serder|undefined = undefined
let serder: Serder | undefined = undefined
if (delpre == undefined) {
serder = incept({
keys: keys!,
Expand Down Expand Up @@ -209,7 +209,7 @@ export class Identifier {
}
jsondata[algo] = keeper.params()

this.client.pidx = this.client.pidx + 1
this.client.pidx = this.client.pidx + 1
let res = this.client.fetch("/identifiers", "POST", jsondata)
return new EventResult(serder, sigs, res)
}
Expand All @@ -232,7 +232,7 @@ export class Identifier {

data = Array.isArray(data) ? data : [data]

let serder = interact({ pre: pre, sn: sn + 1, data: data, dig: dig, version: undefined, kind: undefined })
let [ , serder] = interact({ pre: pre, sn: sn + 1, data: data, dig: dig, version: undefined, kind: undefined })
let keeper = this.client!.manager!.get(hab)
let sigs = keeper.sign(b(serder.raw))

Expand All @@ -253,7 +253,7 @@ export class Identifier {
* @param {RotateIdentifierArgs} [kargs] Optional parameters requiered to generate the rotation event
* @returns {Promise<EventResult>} A promise to the rotation event result
*/
async rotate(name: string, kargs: RotateIdentifierArgs={}): Promise<EventResult> {
async rotate(name: string, kargs: RotateIdentifierArgs = {}): Promise<EventResult> {

let transferable = kargs.transferable ?? true
let ncode = kargs.ncode ?? MtrDex.Ed25519_Seed
Expand All @@ -277,16 +277,16 @@ export class Identifier {
// if nsith is None: # compute default from newly rotated digers above
if (nsith == undefined) nsith = `${Math.max(1, Math.ceil(ncount / 2)).toString(16)}`

let cst = new Tholder({sith: isith}).sith // current signing threshold
let nst = new Tholder({sith: nsith}).sith // next signing threshold
let cst = new Tholder({ sith: isith }).sith // current signing threshold
let nst = new Tholder({ sith: nsith }).sith // next signing threshold

// Regenerate next keys to sign rotation event
let keeper = this.client.manager!.get(hab)
// Create new keys for next digests
let ncodes = kargs.ncodes ?? new Array(ncount).fill(ncode)

let states = kargs.states == undefined? [] : kargs.states
let rstates = kargs.rstates == undefined? [] : kargs.rstates
let states = kargs.states == undefined ? [] : kargs.states
let rstates = kargs.rstates == undefined ? [] : kargs.rstates
let [keys, ndigs] = keeper!.rotate(ncodes, transferable, states, rstates)

let cuts = kargs.cuts ?? []
Expand Down
10 changes: 9 additions & 1 deletion src/keri/app/clienting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { KeyManager } from "../core/keeping"
import { Identifier } from "./aiding"
import { Contacts, Challenges } from "./contacting"
import { Oobis, Operations, KeyEvents, KeyStates } from "./coring"
import { Credentials, Registries, Schemas, } from './credentialing'
import { Credentials, Registries, Schemas, Ipex } from './credentialing'
import { Notifications } from "./notifying"
import { Escrows } from "./escrowing"
import { Groups } from "./grouping"
Expand Down Expand Up @@ -425,4 +425,12 @@ export class SignifyClient {
exchanges(): Exchanges {
return new Exchanges(this)
}

/**
* Get ipex resource
* @returns {Ipex}
* */
ipex(): Ipex {
return new Ipex(this)
}
}
26 changes: 14 additions & 12 deletions src/keri/app/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,18 @@ export class Controller {

approveDelegation(_agent: Agent) {

let seqner = new Seqner({sn: _agent.sn})
let anchor = {i: _agent.pre, s: seqner.snh, d: _agent.said}
let seqner = new Seqner({ sn: _agent.sn })
let anchor = { i: _agent.pre, s: seqner.snh, d: _agent.said }
let sn = new CesrNumber({}, undefined, this.serder.ked["s"]).num + 1
this.serder = interact({
let [ , serder] = interact({
pre: this.serder.pre,
dig: this.serder.ked["d"],
sn: sn,
data: [anchor],
version: Versionage,
kind: Serials.JSON})
kind: Serials.JSON
})
this.serder = serder
return [this.signer.sign(this.serder.raw, 0).qb64]
}

Expand Down Expand Up @@ -221,13 +223,13 @@ export class Controller {
// Now we have the AID salt, use it to verify against the current public keys
let acreator = new SaltyCreator(dnxt, salty["tier"], salty["stem"])
let signers = acreator.create(
salty["icodes"],
undefined,
MtrDex.Ed25519_Seed,
salty["transferable"],
salty["pidx"],
0,
salty["kidx"],
salty["icodes"],
undefined,
MtrDex.Ed25519_Seed,
salty["transferable"],
salty["pidx"],
0,
salty["kidx"],
false)
let _signers = []
for (let signer of signers.signers) {
Expand Down Expand Up @@ -262,7 +264,7 @@ export class Controller {
for (let signer of signers) {
_signers.push(signer.verfer.qb64)
}

if (pubs.join(",") != _signers.join(",")) {
throw new Error(`unable to rotate, validation of encrypted public keys ${pubs} failed`)
}
Expand Down
Loading
Loading