diff --git a/src/compiler.c b/src/compiler.c index 126db58..ae50de5 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -1103,6 +1103,12 @@ hashfunctions (Tac tcstart) } knowledgeAddInverseKeys (sys->know, hfuncs->term, hinvs->term); hfuncs->term->stype = termlistAdd (NULL, TERM_Function); + if (tcstart->t3.tac == NULL) + { + // Not secret + knowledgeAddTerm (sys->know, hfuncs->term); + knowledgeAddPublicFunction (sys->know, hfuncs->term); + } hinvs->term->stype = termlistAdd (NULL, TERM_Function); hfuncs = hfuncs->next; hinvs = hinvs->next; diff --git a/src/parser.y b/src/parser.y index 4d8c01d..ed96dd6 100644 --- a/src/parser.y +++ b/src/parser.y @@ -368,11 +368,11 @@ declaration : secretpref CONST basictermlist typeinfo1 ';' t->t1.tac= $2; $$ = t; } - | HASHFUNCTION basictermlist ';' + | secretpref funcORhash basictermlist ';' { Tac t = tacCreate(TAC_HASHFUNCTION); - t->t1.tac = $2; + t->t1.tac = $3; t->t2.tac = tacCreate(TAC_UNDEF); - t->t3.tac = NULL; // Not secret: public + t->t3.tac = $1; // secret or not $$ = t; } | macrodecl @@ -381,6 +381,12 @@ declaration : secretpref CONST basictermlist typeinfo1 ';' } ; +funcORhash : FUNCTION + { } + | HASHFUNCTION + { } + ; + secretpref : /* empty */ { $$ = NULL;