public final ChainResult calculateOutputHash ( long level ) throws KSIException { // TODO task KSIJAVAAPI-207 If the aggregation hash chain component contains the `input data' field, hash the value part of the field // using the hash algorithm specified by the first octet of the `input hash' field and verify that the result of // hashing `input data' equals `input hash'; terminate with a consistency error if they do not match.(spec. 4.1.1.2) // TODO task KSIJAVAAPI-207 if current aggregation hash chain isn't the first component of the hash chain and the chain // contains 'input data' field then terminate with a format error. (spec 4.1.1.2) DataHash lastHash = inputHash ; long currentLevel = level ; for ( AggregationChainLink aggregationChainLink : chain ) { ChainResult step = aggregationChainLink . calculateChainStep ( lastHash . getImprint ( ) , currentLevel , aggregationAlgorithm ) ; lastHash = step . getOutputHash ( ) ; currentLevel = step . getLevel ( ) ; } this . outputHash = lastHash ; return new InMemoryChainResult ( lastHash , currentLevel ) ; }
Calculate hash chain output hash .