Пример #1
0
        public BlockBase CreateUtxoRegisterBlock(UtxoConfidentialBase confidentialBase, byte[] otsk, int actualAssetPos)
        {
            byte[] msg = ConfidentialAssetsHelper.FastHash256(confidentialBase.RawData.ToArray());

            RegistryRegisterUtxoConfidentialBlock registryRegisterUtxoConfidentialBlock = new RegistryRegisterUtxoConfidentialBlock
            {
                SyncBlockHeight      = confidentialBase.SyncBlockHeight,
                Nonce                = confidentialBase.Nonce,
                PowHash              = confidentialBase.PowHash,
                ReferencedPacketType = confidentialBase.PacketType,
                ReferencedBlockType  = confidentialBase.BlockType,
                DestinationKey       = confidentialBase.DestinationKey,
                KeyImage             = confidentialBase.KeyImage,
                ReferencedBodyHash   = _hashCalculation.CalculateHash(confidentialBase.RawData),
                TransactionPublicKey = confidentialBase.TransactionPublicKey,
                TagId                = confidentialBase.TagId,
                PublicKeys           = confidentialBase.PublicKeys,
                Signatures           = ConfidentialAssetsHelper.GenerateRingSignature(msg, confidentialBase.KeyImage.Value.ToArray(), confidentialBase.PublicKeys.Select(p => p.Value.ToArray()).ToArray(), otsk, actualAssetPos)
            };

            return(registryRegisterUtxoConfidentialBlock);
        }
Пример #2
0
        protected override Memory <byte> ParseUtxoConfidential(ushort version, Memory <byte> spanBody, out UtxoConfidentialBase utxoConfidentialBase)
        {
            if (version == 1)
            {
                int readBytes = 0;

                PacketType referencedPacketType = (PacketType)BinaryPrimitives.ReadUInt16LittleEndian(spanBody.Span);
                readBytes += 2;

                ushort referencedBlockType = BinaryPrimitives.ReadUInt16LittleEndian(spanBody.Span.Slice(readBytes));
                readBytes += 2;

                byte[] referencedBlockHash = spanBody.Slice(readBytes, Globals.DEFAULT_HASH_SIZE).ToArray();
                readBytes += Globals.DEFAULT_HASH_SIZE;

                byte[] referencedTarget = spanBody.Slice(readBytes, Globals.NODE_PUBLIC_KEY_SIZE).ToArray();
                readBytes += Globals.NODE_PUBLIC_KEY_SIZE;

                byte[] referencedTransactionKey = spanBody.Slice(readBytes, Globals.NODE_PUBLIC_KEY_SIZE).ToArray();
                readBytes += Globals.NODE_PUBLIC_KEY_SIZE;

                RegistryRegisterUtxoConfidentialBlock registryRegisterUtxoConfidentialBlock = new RegistryRegisterUtxoConfidentialBlock
                {
                    ReferencedPacketType = referencedPacketType,
                    ReferencedBlockType  = referencedBlockType,
                    ReferencedBodyHash   = referencedBlockHash,
                    DestinationKey       = referencedTarget,
                    TransactionPublicKey = referencedTransactionKey
                };

                utxoConfidentialBase = registryRegisterUtxoConfidentialBlock;

                return(spanBody.Slice(readBytes));
            }

            throw new BlockVersionNotSupportedException(version, BlockType);
        }