From c75341d0529cf3cde60f057d3cd931c1e5dd225f Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Fri, 10 Jun 2016 16:36:22 +0200 Subject: add (M+1)st Price auction global-view script --- gp-scripts/m+1stPrice | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'gp-scripts') diff --git a/gp-scripts/m+1stPrice b/gp-scripts/m+1stPrice index 8407e96..a6ac17c 100644 --- a/gp-scripts/m+1stPrice +++ b/gp-scripts/m+1stPrice @@ -5,6 +5,8 @@ \\ Adapt the following values to your needs \\\\\\\\\\\\ +\\ auction parameter +M = 1 \\ amount of bidders n = 2^3 \\ amount of possible prices @@ -16,20 +18,18 @@ bid = vector(n,i,random(k)+1) \\bid = vector(n,i,(i+1)%2) \\ second bidder wins (with ties) \\ prime finite field setup (result may be ambiguous if your prime is too small, 4*n*k seems to work fine) -q = prime(4*n*k) - -\\\\\\\\\\\\ -\\ SETUP -\\\\\\\\\\\\ - -\\ p not needed? wat? -\\p = 47 - -\\ get generator / primitive element for Z_q -var = 'x \\ copy pasta from internet -pe=ffgen(minpoly(ffprimroot(ffgen(ffinit(q,1))),var),var) \\ get primitive element -1/(fforder(pe) == q-1) \\ error out, if ord(pe) is wrong -g = Mod(eval(Str(pe)), q) \\ dirty hack to convert t_FFELEM to t_INT +\\p = 263 +\\q = (p-1)/2 +\\ use save prime p +q = prime(2^12) +p = 2*q + 1 + +\\ get generator / primitive element for G_q +\\var = 'x \\ copy pasta from internet +\\pe=ffgen(minpoly(ffprimroot(ffgen(ffinit(p,1))),var),var) \\ get primitive element +\\1/(fforder(pe) == p-1) \\ error out, if ord(pe) is wrong +\\g = Mod(eval(Str(pe))^2, p) \\ dirty hack to convert t_FFELEM to t_INT +g = Mod(4, p) \\\\\\\\\\\\ \\ PROLOG @@ -66,8 +66,8 @@ beta = matrix(n,k,i,j, g^r[i,j]) \\ multiplicative shares \\ first index level = owning agent id (multiplicative share) \\ second index level = agent id, price id -Gamma = vector(n,a,matrix(n,k,i,j, ( prod(h=1,n,prod(d=j+1,k,alpha[h,d])) * prod(d=1,j-1,alpha[i,d]) * prod(h=1,i-1,alpha[h,j]) )^m[a][i,j] )) -Delta = vector(n,a,matrix(n,k,i,j, ( prod(h=1,n,prod(d=j+1,k, beta[h,d])) * prod(d=1,j-1, beta[i,d]) * prod(h=1,i-1, beta[h,j]) )^m[a][i,j] )) +Gamma = vector(n,a,matrix(n,k,i,j, ( prod(h=1,n,prod(d=j,k,alpha[h,d])*prod(d=j+1,k,alpha[h,d])) * prod(d=1,j,alpha[i,d])^(2*M+2) / g^(2*M+1) )^(m[a][i,j]) )) +Delta = vector(n,a,matrix(n,k,i,j, ( prod(h=1,n,prod(d=j,k, beta[h,d])*prod(d=j+1,k, beta[h,d])) * prod(d=1,j, beta[i,d])^(2*M+2) )^(m[a][i,j]) )) \\\\\\\\\\\\ \\ ROUND3 @@ -84,8 +84,7 @@ Phi = vector(n,a,matrix(n,k,i,j, prod(h=1,n,Delta[h][i,j])^x[a] )) \\ winner matrix v = matrix(n,k,a,j, prod(i=1,n,Gamma[i][a,j]) / prod(i=1,n,Phi[i][a,j]) ) - vi = lift(v) print("bids are: ", bid) -for(X=1,n, if(vecmin(vi[X,])==1, print("And the winner is ", X) )) +for(X=1,n, if(vecmin(vi[X,],&i)==1, print("And the winner is ", X, " with the price ", i) )) -- cgit v1.2.3