@@ -77,16 +77,16 @@ static sha256_midstate amrIV(tag_t tag) {
7777 SIMPLICITY_UNREACHABLE ;
7878}
7979
80- /* Given the IMR of a jet specification, return the CMR for a jet that implements that specification.
80+ /* Given the identity hash of a jet specification, return the CMR for a jet that implements that specification.
8181 *
82- * Precondition: uint32_t imr [8]
82+ * Precondition: uint32_t ih [8]
8383 */
84- static sha256_midstate mkJetCMR (uint32_t * imr , uint_fast64_t weight ) {
84+ static sha256_midstate mkJetCMR (uint32_t * ih , uint_fast64_t weight ) {
8585 sha256_midstate result = jetIV ;
8686 uint32_t block [16 ] = {0 };
8787 block [6 ] = (uint32_t )(weight >> 32 );
8888 block [7 ] = (uint32_t )weight ;
89- memcpy (& block [8 ], imr , sizeof (uint32_t [8 ]));
89+ memcpy (& block [8 ], ih , sizeof (uint32_t [8 ]));
9090 simplicity_sha256_compression (result .s , block );
9191
9292 return result ;
@@ -100,7 +100,7 @@ sha256_midstate simplicity_computeWordCMR(const bitstring* value, size_t n) {
100100 /* 'stack' is an array of 30 hashes consisting of 8 'uint32_t's each. */
101101 uint32_t stack [8 * 30 ] = {0 };
102102 uint32_t * stack_ptr = stack ;
103- sha256_midstate imr = identityIV ;
103+ sha256_midstate ih = identityIV ;
104104 simplicity_assert (n < 32 );
105105 simplicity_assert ((size_t )1 << n == value -> len );
106106 /* Pass 1: Compute the CMR for the expression that writes 'value'.
@@ -135,14 +135,14 @@ sha256_midstate simplicity_computeWordCMR(const bitstring* value, size_t n) {
135135 /* value->len is a power of 2.*/
136136 simplicity_assert (stack_ptr == stack + 8 );
137137
138- /* Pass 2: Compute the IMR for the expression by adding the type roots of ONE and TWO^(2^n) to the CMR. */
139- simplicity_sha256_compression (imr .s , stack );
138+ /* Pass 2: Compute the identity hash for the expression by adding the type roots of ONE and TWO^(2^n) to the CMR. */
139+ simplicity_sha256_compression (ih .s , stack );
140140 memcpy (& stack [0 ], word_type_root [0 ].s , sizeof (uint32_t [8 ]));
141141 memcpy (& stack [8 ], word_type_root [n + 1 ].s , sizeof (uint32_t [8 ]));
142- simplicity_sha256_compression (imr .s , stack );
142+ simplicity_sha256_compression (ih .s , stack );
143143
144- /* Pass 3: Compute the jet's CMR from the specificion's IMR . */
145- return mkJetCMR (imr .s , ((uint_fast64_t )1 << n ));
144+ /* Pass 3: Compute the jet's CMR from the specificion's identity hash . */
145+ return mkJetCMR (ih .s , ((uint_fast64_t )1 << n ));
146146}
147147
148148/* Given a well-formed dag[i + 1], such that for all 'j', 0 <= 'j' < 'i',
@@ -192,45 +192,45 @@ void simplicity_computeCommitmentMerkleRoot(dag_node* dag, const uint_fast32_t i
192192 }
193193}
194194
195- /* Computes the identity Merkle roots of every subexpression in a well-typed 'dag' with witnesses.
196- * 'imr [i]' is set to the identity Merkle root of the subexpression 'dag[i]'.
197- * When 'HIDDEN == dag[i].tag', then 'imr [i]' is instead set to a hidden root hash for that hidden node.
195+ /* Computes the identity hash roots of every subexpression in a well-typed 'dag' with witnesses.
196+ * 'ihr [i]' is set to the identity hash of the root of the subexpression 'dag[i]'.
197+ * When 'HIDDEN == dag[i].tag', then 'ihr [i]' is instead set to a hidden root hash for that hidden node.
198198 *
199- * Precondition: sha256_midstate imr [len];
199+ * Precondition: sha256_midstate ihr [len];
200200 * dag_node dag[len] and 'dag' is well-typed with 'type_dag' and contains witnesses.
201201 */
202- static void computeIdentityMerkleRoot (sha256_midstate * imr , const dag_node * dag , const type * type_dag , const uint_fast32_t len ) {
202+ static void computeIdentityHashRoots (sha256_midstate * ihr , const dag_node * dag , const type * type_dag , const uint_fast32_t len ) {
203203 /* Pass 1 */
204204 for (size_t i = 0 ; i < len ; ++ i ) {
205205 uint32_t block [16 ] = {0 };
206206 size_t j = 8 ;
207207
208208 /* For jets, the first pass identity Merkle root is the same as their commitment Merkle root. */
209- imr [i ] = HIDDEN == dag [i ].tag ? dag [i ].cmr
209+ ihr [i ] = HIDDEN == dag [i ].tag ? dag [i ].cmr
210210 : JET == dag [i ].tag ? dag [i ].cmr
211211 : WORD == dag [i ].tag ? dag [i ].cmr
212212 : imrIV (dag [i ].tag );
213213 switch (dag [i ].tag ) {
214214 case WITNESS :
215215 simplicity_sha256_bitstring (block , & dag [i ].compactValue );
216216 memcpy (block + 8 , type_dag [WITNESS_B (dag , type_dag , i )].typeMerkleRoot .s , sizeof (uint32_t [8 ]));
217- simplicity_sha256_compression (imr [i ].s , block );
217+ simplicity_sha256_compression (ihr [i ].s , block );
218218 break ;
219219 case COMP :
220220 case ASSERTL :
221221 case ASSERTR :
222222 case CASE :
223223 case PAIR :
224224 case DISCONNECT :
225- memcpy (block + j , imr [dag [i ].child [1 ]].s , sizeof (uint32_t [8 ]));
225+ memcpy (block + j , ihr [dag [i ].child [1 ]].s , sizeof (uint32_t [8 ]));
226226 j = 0 ;
227227 /*@fallthrough@*/
228228 case INJL :
229229 case INJR :
230230 case TAKE :
231231 case DROP :
232- memcpy (block + j , imr [dag [i ].child [0 ]].s , sizeof (uint32_t [8 ]));
233- simplicity_sha256_compression (imr [i ].s , block );
232+ memcpy (block + j , ihr [dag [i ].child [0 ]].s , sizeof (uint32_t [8 ]));
233+ simplicity_sha256_compression (ihr [i ].s , block );
234234 case IDEN :
235235 case UNIT :
236236 case HIDDEN :
@@ -245,16 +245,16 @@ static void computeIdentityMerkleRoot(sha256_midstate* imr, const dag_node* dag,
245245 uint32_t block [16 ] = {0 };
246246
247247 if (HIDDEN == dag [i ].tag ) {
248- memcpy (block + 8 , imr [i ].s , sizeof (uint32_t [8 ]));
249- imr [i ] = hiddenIV ;
250- simplicity_sha256_compression (imr [i ].s , block );
248+ memcpy (block + 8 , ihr [i ].s , sizeof (uint32_t [8 ]));
249+ ihr [i ] = hiddenIV ;
250+ simplicity_sha256_compression (ihr [i ].s , block );
251251 } else {
252- memcpy (block + 8 , imr [i ].s , sizeof (uint32_t [8 ]));
253- imr [i ] = identityIV ;
254- simplicity_sha256_compression (imr [i ].s , block );
252+ memcpy (block + 8 , ihr [i ].s , sizeof (uint32_t [8 ]));
253+ ihr [i ] = identityIV ;
254+ simplicity_sha256_compression (ihr [i ].s , block );
255255 memcpy (block , type_dag [dag [i ].sourceType ].typeMerkleRoot .s , sizeof (uint32_t [8 ]));
256256 memcpy (block + 8 , type_dag [dag [i ].targetType ].typeMerkleRoot .s , sizeof (uint32_t [8 ]));
257- simplicity_sha256_compression (imr [i ].s , block );
257+ simplicity_sha256_compression (ihr [i ].s , block );
258258 }
259259 }
260260}
@@ -559,30 +559,30 @@ simplicity_err simplicity_fillWitnessData(dag_node* dag, type* type_dag, const u
559559 return SIMPLICITY_NO_ERROR ;
560560}
561561
562- /* Verifies that identity Merkle roots of every subexpression in a well-typed 'dag' with witnesses are all unique,
562+ /* Verifies that identity hash of every subexpression in a well-typed 'dag' with witnesses are all unique,
563563 * including that each hidden root hash for every 'HIDDEN' node is unique.
564564 *
565- * if 'imr ' is not NULL, then '*imr ' is set to the identity Merkle root of the 'dag'.
565+ * if 'ihr ' is not NULL, then '*ihr ' is set to the identity hash of the root of the 'dag'.
566566 *
567567 * If malloc fails, returns 'SIMPLICITY_ERR_MALLOC'.
568- * If all the identity Merkle roots (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
568+ * If all the identity hahes (and hidden roots) are all unique, returns 'SIMPLICITY_NO_ERROR'.
569569 * Otherwise returns 'SIMPLICITY_ERR_UNSHARED_SUBEXPRESSION'.
570570 *
571571 * Precondition: dag_node dag[len] and 'dag' is well-typed with 'type_dag' and contains witnesses.
572572 */
573- simplicity_err simplicity_verifyNoDuplicateIdentityRoots (sha256_midstate * imr , const dag_node * dag , const type * type_dag , const uint_fast32_t dag_len ) {
573+ simplicity_err simplicity_verifyNoDuplicateIdentityHashes (sha256_midstate * ihr , const dag_node * dag , const type * type_dag , const uint_fast32_t dag_len ) {
574574 simplicity_assert (0 < dag_len );
575575 simplicity_assert (dag_len <= DAG_LEN_MAX );
576- sha256_midstate * imr_buf = simplicity_malloc ((size_t )dag_len * sizeof (sha256_midstate ));
577- if (!imr_buf ) return SIMPLICITY_ERR_MALLOC ;
576+ sha256_midstate * ih_buf = simplicity_malloc ((size_t )dag_len * sizeof (sha256_midstate ));
577+ if (!ih_buf ) return SIMPLICITY_ERR_MALLOC ;
578578
579- computeIdentityMerkleRoot ( imr_buf , dag , type_dag , dag_len );
579+ computeIdentityHashRoots ( ih_buf , dag , type_dag , dag_len );
580580
581- if (imr ) * imr = imr_buf [dag_len - 1 ];
581+ if (ihr ) * ihr = ih_buf [dag_len - 1 ];
582582
583- int result = simplicity_hasDuplicates (imr_buf , dag_len );
583+ int result = simplicity_hasDuplicates (ih_buf , dag_len );
584584
585- simplicity_free (imr_buf );
585+ simplicity_free (ih_buf );
586586
587587 switch (result ) {
588588 case -1 : return SIMPLICITY_ERR_MALLOC ;
0 commit comments