const conf = require('ocore/conf.js');
const objectHash = require('ocore/object_hash.js');
let bPublic = false; // ask user if they want public or private profile
function hideProfile(profile, bPublic = false){
const composer = require('ocore/composer.js');
for (let field in profile){
let value = profile[field];
let blinding = composer.generateBlinding();
let hidden_value = objectHash.getBase64Hash([value, blinding], true);
hidden_profile[field] = hidden_value;
src_profile[field] = [value, blinding];
first_name: profile.first_name,
last_name: profile.last_name,
country: profile.country,
public_profile = profile;
public_profile.user_id = objectHash.getBase64Hash([shortProfile, conf.salt]);
return [public_profile, null];
profile_hash: objectHash.getBase64Hash(hidden_profile, true),
user_id: objectHash.getBase64Hash([shortProfile, conf.salt])
return [public_profile, src_profile];
first_name: "", // required
last_name: "", // required
us_state: "", // optional
for (let field in profile){
if (typeof profile[field] === 'undefined' || profile[field] === null || profile[field] === '') {
// remove negative values, except number 0
// convert everything else to string
profile[field] = String(profile[field]);
let [public_data, src_profile] = hideProfile(profile, bPublic);
payload_location: 'inline',