Pack() 공개 메소드

Pack the record to storable data
public Pack ( RSAParameters privKey ) : byte[]
privKey System.Security.Cryptography.RSAParameters The private key to sign the data with
리턴 byte[]
예제 #1
0
        /// <summary>
        ///     - Verifies that we are allowed to update this chain
        ///     - Enrolls a new candidate chain with a CandidateOldVersionRecord referencing the old chain
        ///     - Adds a OldVersionRecord to the old chain referencing the new chain
        ///     - Adds a ChainUpdateRecord to the chain requesting update, forwarding it to the new chain.
        ///     This operation is irreversable.
        /// </summary>
        /// <param name="newCandidate">The updated candidate information</param>
        /// <param name="password">The password provided by the candidate</param>
        /// <param name="fp">The fingerprint to verify against</param>
        /// <param name="privKey">The private key to pack the data with</param>
        /// <param name="chainToUpdate">The chain ID of the chain to be updated</param>
        /// <returns>The chain ID pointing to the updated candidate</returns>
        public static byte[] UpdateCandidate(Candidate newCandidate, string password, Fingerprint fp,
                                             RSAParameters privKey, byte[] chainToUpdate)
        {
            if (FullVerifyFromChain(chainToUpdate, password, fp, privKey) < 50f)
            {
                throw new AccessConfidenceTooLowException("Access confidence too low to update candidate.");
            }

            var newChainId = EnrollCandidate(newCandidate, password, privKey);

            var ovr = new CandidateOldVersionRecord(chainToUpdate, newChainId);
            var cur = new CandidateUpdatedRecord(chainToUpdate, newChainId);

            var oldRecordEntry = Entry.NewEntry(ovr.Pack(privKey), null, newChainId);
            var newRecordEntry = Entry.NewEntry(cur.Pack(privKey), null, chainToUpdate);

            Entry.CommitEntry(oldRecordEntry, FactomWallet);
            Entry.CommitEntry(newRecordEntry, FactomWallet);

            Thread.Sleep(10100);

            Entry.RevealEntry(oldRecordEntry);
            Entry.RevealEntry(newRecordEntry);

            return(newChainId);
        }
예제 #2
0
        /// <summary>
        ///     - Verifies that we are allowed to update this chain
        ///     - Enrolls a new candidate chain with a CandidateOldVersionRecord referencing the old chain
        ///     - Adds a OldVersionRecord to the old chain referencing the new chain
        ///     - Adds a ChainUpdateRecord to the chain requesting update, forwarding it to the new chain.
        ///     This operation is irreversable.
        /// </summary>
        /// <param name="newCandidate">The updated candidate information</param>
        /// <param name="password">The password provided by the candidate</param>
        /// <param name="fp">The fingerprint to verify against</param>
        /// <param name="privKey">The private key to pack the data with</param>
        /// <param name="chainToUpdate">The chain ID of the chain to be updated</param>
        /// <returns>The chain ID pointing to the updated candidate</returns>
        public static byte[] UpdateCandidate(Candidate newCandidate, string password, Fingerprint fp,
            RSAParameters privKey, byte[] chainToUpdate)
        {
            if (FullVerifyFromChain(chainToUpdate, password, fp, privKey) < 50f)
                throw new AccessConfidenceTooLowException("Access confidence too low to update candidate.");

            var newChainId = EnrollCandidate(newCandidate, password, privKey);

            var ovr = new CandidateOldVersionRecord(chainToUpdate, newChainId);
            var cur = new CandidateUpdatedRecord(chainToUpdate, newChainId);

            var oldRecordEntry = Entry.NewEntry(ovr.Pack(privKey), null, newChainId);
            var newRecordEntry = Entry.NewEntry(cur.Pack(privKey), null, chainToUpdate);

            Entry.CommitEntry(oldRecordEntry, FactomWallet);
            Entry.CommitEntry(newRecordEntry, FactomWallet);

            Thread.Sleep(10100);

            Entry.RevealEntry(oldRecordEntry);
            Entry.RevealEntry(newRecordEntry);

            return newChainId;
        }