Esempio n. 1
0
        /// <summary>
        /// Sign document hash.
        /// </summary>
        /// <param name="hash">document hash</param>
        /// <param name="level">The document hash node level value in the aggregation tree</param>
        /// <returns>KSI signature</returns>
        public IKsiSignature Sign(DataHash hash, uint level = 0)
        {
            if (hash == null)
            {
                throw new ArgumentNullException(nameof(hash));
            }

            return(_ksiService.Sign(hash, level));
        }
Esempio n. 2
0
        /// <summary>
        /// Sign given hashes. Returns uni-signatures.
        /// </summary>
        public IEnumerable <IKsiSignature> Sign()
        {
            _canAddItems = false;

            if (_leafNodes.Count == 0)
            {
                return(new List <IKsiSignature>());
            }

            TreeNode root = _treeBuilder.GetTreeRoot();

            if (root.Left == null && root.Right == null)
            {
                Logger.Debug("Only one node in the tree. Signing the hash. Level: {0}; Hash: {1}", root.Level, root.Hash);
                return(new List <IKsiSignature>()
                {
                    _ksiService.Sign(root.Hash, root.Level)
                });
            }

            Logger.Debug("Signing root node hash. Level: {0}; Hash: {1}", root.Level, root.Hash);
            SignRequestResponsePayload signResponsePayload = _ksiService.GetSignResponsePayload(_ksiService.BeginSign(root.Hash, root.Level, null, null));

            return(CreateUniSignatures(new KsiSignature(false, false, signResponsePayload.GetSignatureChildTags())));
        }