public BDSStateMap withWOTSDigest(ASN1ObjectIdentifier digestName) { BDSStateMap newStateMap = new BDSStateMap(); for (Iterator<Integer> keys = bdsState.keySet().iterator(); keys.hasNext();) { Integer key = keys.next(); newStateMap.bdsState.put(key, bdsState.get(key).withWOTSDigest(digestName)); } return newStateMap; } }
BDSStateMap(XMSSMTParameters params, long globalIndex, byte[] publicSeed, byte[] secretKeySeed) { for (long index = 0; index < globalIndex; index++) { updateState(params, index, publicSeed, secretKeySeed); } }
if (this.get(0) == null || indexLeaf == 0) this.put(0, new BDS(xmssParams, publicSeed, secretKeySeed, otsHashAddress)); this.update(0, publicSeed, secretKeySeed, otsHashAddress); && XMSSUtil.isNewAuthenticationPathNeeded(globalIndex, xmssHeight, layer)) if (this.get(layer) == null) this.put(layer, new BDS(params.getXMSSParameters(), publicSeed, secretKeySeed, otsHashAddress)); this.update(layer, publicSeed, secretKeySeed, otsHashAddress);
if (privateKey.getBDSState().isEmpty()) if (bdsState.get(0) == null || indexLeaf == 0) bdsState.put(0, new BDS(xmssParams, privateKey.getPublicSeed(), privateKey.getSecretKeySeed(), otsHashAddress)); .withWOTSPlusSignature(wotsPlusSignature).withAuthPath(bdsState.get(0).getAuthenticationPath()) .build(); XMSSNode root = bdsState.get(layer - 1).getRoot(); if (bdsState.get(layer) == null || XMSSUtil.isNewBDSInitNeeded(globalIndex, xmssHeight, layer)) bdsState.put(layer, new BDS(xmssParams, privateKey.getPublicSeed(), privateKey.getSecretKeySeed(), otsHashAddress)); .withAuthPath(bdsState.get(layer).getAuthenticationPath()).build();
bdsState = bdsImport.withWOTSDigest(DigestUtil.getDigestOID(builder.xmss.getDigest().getAlgorithmName())); bdsState = new BDSStateMap(params, builder.index, tmpPublicSeed, tmpSecretKeySeed); bdsState = new BDSStateMap();
/** * Generate a new XMSSMT private key / public key pair. */ public AsymmetricCipherKeyPair generateKeyPair() { XMSSMTPrivateKeyParameters privateKey; XMSSMTPublicKeyParameters publicKey; /* generate XMSSMT private key */ privateKey = generatePrivateKey(new XMSSMTPrivateKeyParameters.Builder(params).build().getBDSState()); /* import to xmss */ xmssParams.getWOTSPlus().importKeys(new byte[params.getDigestSize()], privateKey.getPublicSeed()); /* get root */ int rootLayerIndex = params.getLayers() - 1; OTSHashAddress otsHashAddress = (OTSHashAddress)new OTSHashAddress.Builder().withLayerAddress(rootLayerIndex) .build(); /* store BDS instance of root xmss instance */ BDS bdsRoot = new BDS(xmssParams, privateKey.getPublicSeed(), privateKey.getSecretKeySeed(), otsHashAddress); XMSSNode root = bdsRoot.getRoot(); privateKey.getBDSState().put(rootLayerIndex, bdsRoot); /* set XMSS^MT root / create public key */ privateKey = new XMSSMTPrivateKeyParameters.Builder(params).withSecretKeySeed(privateKey.getSecretKeySeed()) .withSecretKeyPRF(privateKey.getSecretKeyPRF()).withPublicSeed(privateKey.getPublicSeed()) .withRoot(root.getValue()).withBDSState(privateKey.getBDSState()).build(); publicKey = new XMSSMTPublicKeyParameters.Builder(params).withRoot(root.getValue()) .withPublicSeed(privateKey.getPublicSeed()).build(); return new AsymmetricCipherKeyPair(publicKey, privateKey); }
keyBuilder.withBDSState(bdsState.withWOTSDigest(treeDigest));
BDSStateMap(BDSStateMap stateMap, XMSSMTParameters params, long globalIndex, byte[] publicSeed, byte[] secretKeySeed) { for (Iterator it = stateMap.bdsState.keySet().iterator(); it.hasNext();) { Integer key = (Integer)it.next(); bdsState.put(key, stateMap.bdsState.get(key)); } updateState(params, globalIndex, publicSeed, secretKeySeed); }
public XMSSMTPrivateKeyParameters getNextKey() { BDSStateMap newState = new BDSStateMap(bdsState, params, this.getIndex(), publicSeed, secretKeySeed); return new XMSSMTPrivateKeyParameters.Builder(params).withIndex(index + 1) .withSecretKeySeed(secretKeySeed).withSecretKeyPRF(secretKeyPRF) .withPublicSeed(publicSeed).withRoot(root) .withBDSState(newState).build(); } }