public class KsiBlockSigner extends Object implements BlockSigner<List<KSISignature>>
Methods add(DataHash, long, IdentityMetadata)
,
add(DataHash)
and/or
add(DataHash, long, IdentityMetadata)
can be used
to add new input hash to the block signer.
Method sign()
must be called to get the final group of
signatures.
The signatures are returned in the same order as the data hashes were added to block signer.
Current implementation returns one signature per input hash.
Note that this class can not be used multiple times.
The following sample shows how to use KsiBlockSigner
class:
// initialize ksi block signer
KSISigningClient signingClient = getSigningClient();
TreeBuilder treeBuilder = new HashTreeBuilder();
KsiBlockSigner signer = new KsiBlockSignerBuilder()
.setKsiSigningClient(signingClient)
.setTreeBuilder(treeBuilder)
.build();
// add data hashes
signer.add(new DataHash(HashAlgorithm.SHA2_256, new byte[32]));
signer.add(dataHash2);
signer.add(dataHash3);
signer.add(dataHash4, new IdentityMetadata("my_client_id", "my_machine_id", SEQUENCE_NUMBER, REQUEST_TIME));
// call sign methods to get final signatures
List<KSISignature> signatures = signer.sign();
This class isn't thread safe.Constructor and Description |
---|
KsiBlockSigner(KSISigningClient signingClient)
Deprecated.
Use
KsiBlockSignerBuilder instead. |
KsiBlockSigner(KSISigningClient signingClient,
HashAlgorithm algorithm)
Deprecated.
Use
KsiBlockSignerBuilder instead. |
KsiBlockSigner(KSISigningClient signingClient,
KSISignatureFactory signatureFactory,
HashAlgorithm algorithm)
Deprecated.
Use
KsiBlockSignerBuilder instead. |
KsiBlockSigner(KSISigningService signingService)
Deprecated.
Use
KsiBlockSignerBuilder instead. |
KsiBlockSigner(KSISigningService signingService,
HashAlgorithm algorithm)
Deprecated.
Use
KsiBlockSignerBuilder instead. |
KsiBlockSigner(KSISigningService signingService,
KSISignatureFactory signatureFactory,
HashAlgorithm algorithm)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(DataHash dataHash)
Adds a hash to the
KsiBlockSigner . |
boolean |
add(DataHash dataHash,
IdentityMetadata metadata)
Adds a hash and a signature metadata to the
KsiBlockSigner . |
boolean |
add(DataHash dataHash,
long level,
IdentityMetadata metadata)
Adds a hash (with specific level) and a signature metadata to the
KsiBlockSigner . |
List<KSISignature> |
sign()
Creates a block of multiple signatures.
|
@Deprecated public KsiBlockSigner(KSISigningService signingService)
KsiBlockSignerBuilder
instead.KsiBlockSigner
with given KSISigningService
and default hash algorithm
Util.DEFAULT_AGGREGATION_ALGORITHM
. HashTreeBuilder
is always used for aggregation.signingService
- an instance of KSISigningService
.@Deprecated public KsiBlockSigner(KSISigningService signingService, HashAlgorithm algorithm)
KsiBlockSignerBuilder
instead.KsiBlockSigner
with given KSISigningService
and HashAlgorithm
.
HashTreeBuilder
is always used for aggregation.signingService
- an instance of KSISigningService
.algorithm
- hash algorithm to be used.@Deprecated public KsiBlockSigner(KSISigningClient signingClient)
KsiBlockSignerBuilder
instead.KsiBlockSigner
with given KSISigningClient
and default hash algorithm
Util.DEFAULT_AGGREGATION_ALGORITHM
. HashTreeBuilder
is always used for aggregation.signingClient
- an instance of KSISigningClient
.@Deprecated public KsiBlockSigner(KSISigningClient signingClient, HashAlgorithm algorithm)
KsiBlockSignerBuilder
instead.KsiBlockSigner
with given KSISigningClient
and HashAlgorithm
.
HashTreeBuilder
is always used for aggregation.signingClient
- an instance of KSISigningClient
.algorithm
- hash algorithm to be used.@Deprecated public KsiBlockSigner(KSISigningClient signingClient, KSISignatureFactory signatureFactory, HashAlgorithm algorithm)
KsiBlockSignerBuilder
instead.KsiBlockSigner
with given KSISigningClient
,
KSISignatureFactory
and HashAlgorithm
. HashTreeBuilder
is always used for aggregation.signingClient
- an instance of KSISigningClient
.signatureFactory
- an instance of KSISignatureFactory
.algorithm
- hash algorithm to be used.@Deprecated public KsiBlockSigner(KSISigningService signingService, KSISignatureFactory signatureFactory, HashAlgorithm algorithm)
KsiBlockSigner
with given KSISigningService
,
KSISignatureFactory
and HashAlgorithm
. HashTreeBuilder
is always used for aggregation.signingService
- an instance of KSISigningService
.signatureFactory
- an instance of KSISignatureFactory
.algorithm
- hash algorithm to be used.public boolean add(DataHash dataHash, IdentityMetadata metadata) throws KSIException
KsiBlockSigner
.add
in interface BlockSigner<List<KSISignature>>
dataHash
- data hash.metadata
- metadata to be added.KSIException
public boolean add(DataHash dataHash) throws KSIException
KsiBlockSigner
.add
in interface BlockSigner<List<KSISignature>>
dataHash
- data hash.KSIException
public boolean add(DataHash dataHash, long level, IdentityMetadata metadata) throws KSIException
KsiBlockSigner
.add
in interface BlockSigner<List<KSISignature>>
dataHash
- data hash.level
- hash level.metadata
- metadata to be added.KSIException
public List<KSISignature> sign() throws KSIException
sign
in interface BlockSigner<List<KSISignature>>
KSIException
Copyright © 2024 Guardtime. All rights reserved.