projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Makefile to test mp-sqrt.c.
[u/mdw/catacomb]
/
gfshare.c
diff --git
a/gfshare.c
b/gfshare.c
index
bbb0aee
..
a0b102d
100644
(file)
--- a/
gfshare.c
+++ b/
gfshare.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: gfshare.c,v 1.
2 2000/06/18 23:12:15
mdw Exp $
+ * $Id: gfshare.c,v 1.
3 2000/06/22 18:04:13
mdw Exp $
*
* Secret sharing over %$\gf(2^8)$%
*
*
* Secret sharing over %$\gf(2^8)$%
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: gfshare.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: gfshare.c,v $
+ * Revision 1.3 2000/06/22 18:04:13 mdw
+ * Improve secret reconstruction -- compute coefficients as needed rather
+ * than making a big array of them.
+ *
* Revision 1.2 2000/06/18 23:12:15 mdw
* Change typesetting of Galois Field names.
*
* Revision 1.2 2000/06/18 23:12:15 mdw
* Change typesetting of Galois Field names.
*
@@
-43,6
+47,7
@@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
+#include <string.h>
#include <mLib/alloc.h>
#include <mLib/bits.h>
#include <mLib/alloc.h>
#include <mLib/bits.h>
@@
-222,18
+227,20
@@
unsigned gfshare_add(gfshare *s, unsigned x, const octet *y)
void gfshare_combine(gfshare *s, octet *buf)
{
unsigned i, j;
void gfshare_combine(gfshare *s, octet *buf)
{
unsigned i, j;
- octet *v;
/* --- Sanity checking --- */
assert(((void)"Not enough shares yet", s->i == s->t));
/* --- Sanity checking --- */
assert(((void)"Not enough shares yet", s->i == s->t));
- /* ---
Precomputation of coefficient
s --- */
+ /* ---
Grind through the share
s --- */
-
v = XS_ALLOC(s->t
);
+
memset(buf, 0, s->sz
);
for (i = 0; i < s->t; i++) {
unsigned c = 0, ci = 0;
for (i = 0; i < s->t; i++) {
unsigned c = 0, ci = 0;
+
+ /* --- Compute the magic coefficient --- */
+
for (j = 0; j < s->t; j++) {
if (i == j)
continue;
for (j = 0; j < s->t; j++) {
if (i == j)
continue;
@@
-247,21
+254,14
@@
void gfshare_combine(gfshare *s, octet *buf)
if (ci > c)
c += 0xff;
c -= ci;
if (ci > c)
c += 0xff;
c -= ci;
- v[i] = c;
- }
-
/* --- Grind through the shares
--- */
+
/* --- Work out another layer of the secret
--- */
- for (i = 0; i < s->sz; i++) {
- unsigned x = 0;
- for (j = 0; j < s->t; j++) {
- if (s->v[j].y[i])
- x ^= gfexp[v[j] + gflog[s->v[j].y[i]]];
+ for (j = 0; j < s->sz; j++) {
+ if (s->v[i].y[j])
+ buf[j] ^= gfexp[c + gflog[s->v[i].y[j]]];
}
}
- buf[i] = x;
}
}
-
- XS_FREE(v);
}
/*----- Test rig ----------------------------------------------------------*/
}
/*----- Test rig ----------------------------------------------------------*/