Search in sources :

Example 6 with SigSpec

use of snowblossom.proto.SigSpec in project snowblossom by snowblossomcoin.

the class AddressUtil method prettyDisplayAddressSpec.

public static void prettyDisplayAddressSpec(AddressSpec spec, PrintStream out, NetworkParams params, int c_idx, Set<String> signed_list) throws ValidationException {
    AddressSpecHash hash = getHashForSpec(spec);
    String address = getAddressString(params.getAddressPrefix(), hash);
    out.print("AddressSpec " + address);
    out.println(String.format(" %dof%d", spec.getRequiredSigners(), spec.getSigSpecsCount()));
    for (int s = 0; s < spec.getSigSpecsCount(); s++) {
        String key = c_idx + ":" + s;
        boolean signed = false;
        if (signed_list.contains(key))
            signed = true;
        SigSpec sig = spec.getSigSpecs(s);
        String algo = SignatureUtil.getAlgo(sig.getSignatureType());
        out.print("   sigspec:" + algo);
        if (signed) {
            out.print(" SIGNED");
        }
        out.print(" pub:");
        out.println(HexUtil.getHexString(sig.getPublicKey()));
    }
}
Also used : SigSpec(snowblossom.proto.SigSpec) ByteString(com.google.protobuf.ByteString)

Example 7 with SigSpec

use of snowblossom.proto.SigSpec in project snowblossom by snowblossomcoin.

the class AddressUtil method getHashForSpec.

public static AddressSpecHash getHashForSpec(AddressSpec spec, MessageDigest md) {
    try {
        ByteArrayOutputStream byte_out = new ByteArrayOutputStream(200);
        DataOutputStream data_out = new DataOutputStream(byte_out);
        data_out.writeInt(spec.getRequiredSigners());
        data_out.writeInt(spec.getSigSpecsCount());
        for (SigSpec sig_spec : spec.getSigSpecsList()) {
            data_out.writeInt(sig_spec.getSignatureType());
            data_out.writeInt(sig_spec.getPublicKey().size());
            data_out.write(sig_spec.getPublicKey().toByteArray());
        }
        data_out.flush();
        md.update(byte_out.toByteArray());
        return new AddressSpecHash(md.digest());
    } catch (java.io.IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) SigSpec(snowblossom.proto.SigSpec) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

SigSpec (snowblossom.proto.SigSpec)7 ByteString (com.google.protobuf.ByteString)5 Random (java.util.Random)3 MessageDigest (java.security.MessageDigest)2 AddressSpec (snowblossom.proto.AddressSpec)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 ByteBuffer (java.nio.ByteBuffer)1 Test (org.junit.Test)1 AddressSpecHash (snowblossom.lib.AddressSpecHash)1 ChainHash (snowblossom.lib.ChainHash)1 ValidationException (snowblossom.lib.ValidationException)1 SignedMessagePayload (snowblossom.proto.SignedMessagePayload)1