summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/jets/e/ed_point_add.c
blob: 70fe563c2038b2a00ce852b66f98ee806a926c59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/// @file

#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"
#include "urcrypt.h"


  static u3_atom
  _cqee_point_add(u3_atom a,
                 u3_atom b)
  {
    c3_y a_y[32], b_y[32], out_y[32];

    if ( (0 != u3r_bytes_fit(32, a_y, a)) ||
         (0 != u3r_bytes_fit(32, b_y, b)) ||
         (0 != urcrypt_ed_point_add(a_y, b_y, out_y)) ) {
      return u3m_bail(c3__exit);
    }
    else {
      return u3i_bytes(32, out_y);
    }
  }

  u3_noun
  u3wee_point_add(u3_noun cor)
  {
    u3_noun a, b;

    if ( (c3n == u3r_mean(cor, u3x_sam_2, &a,
                               u3x_sam_3, &b, 0)) ||
         (c3n == u3ud(a)) ||
         (c3n == u3ud(b)) )
    {
      return u3m_bail(c3__exit);
    } else {
      return _cqee_point_add(a, b);
    }
  }